2013-12-24 86 views
0

現在,整個屏幕都是可滾動的。Android with Scrollview for half screen only

enter image description here

我想設定的部分B(參照附圖)僅可滾動的同時A部分(視頻部分) 是固定的。以下是我現在的代碼禮儀。請幫忙。

<LinearLayout --some code here--> 
    <ScrollView 
     --some code here--> 
     <LinearLayout 
       android:id="@+id/videoPlayer" 
       > 
      <VideoView 
        --some code here--/> 
      <MediaController 
        android:layout_width="fill_parent" 
        /> 
      <TextView 
        --some code /> 
      <TextView 
        --some code /> 
      <ImageView some code 
       </ImageView> 
      <RelativeLayout --some code here--> 

       <TextView 
         android:id="@+id/scarfPrice" 
         /> 
       <Button android:id="@+id/btnPurchase" 
         /> 
      </RelativeLayout> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

回答

1
<LinearLayout --some code 
     --some code here--> 
     <LinearLayout 
       android:id="@+id/videoPlayer" 
       > 
      <VideoView 
        --some code here--/> 
      <MediaController 
        android:layout_width="fill_parent" 
        /> 
      <ScrollView> 
       <LinearLayout> 
        <TextView 
          --some code /> 
        <TextView 
          --some code /> 
        <ImageView some code 
         </ImageView> 
        <RelativeLayout --some code here--> 

         <TextView 
           android:id="@+id/scarfPrice" 
           /> 
         <Button android:id="@+id/btnPurchase" 
           /> 
        </RelativeLayout> 
       </LinearLayout> 
      </ScrollView> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

tldr:只有包裹內容部分在滾動視圖,但由於滾動視圖只能有一個孩子,另一窩在的LinearLayout滾動視圖內。

編輯:刪除原</ScrollView>和冗餘LinearLayout

<LinearLayout --some code 
     --some code here--> 
      > 
     <VideoView 
       android:id="@+id/videoPlayer" 
       --some code here--/> 
     <MediaController 
       android:layout_width="fill_parent" 
       /> 
     <ScrollView> 
      <LinearLayout> 
       <TextView 
         --some code /> 
       <TextView 
         --some code /> 
       <ImageView some code 
        </ImageView> 
       <RelativeLayout --some code here--> 

        <TextView 
          android:id="@+id/scarfPrice" 
          /> 
        <Button android:id="@+id/btnPurchase" 
          /> 
       </RelativeLayout> 
      </LinearLayout> 
     </ScrollView> 
    </LinearLayout> 
+0

謝謝你的回答。我解決了它。 :d – user2412351

0
<LinearLayout> 
    <LinearLayout android:layout_weight="2"> 
     <!-- Part A --> 
    </LinearLayout> 
    <ScrollView android:layout_weight="3"> 
     <LinearLayout> 
      <!-- Part B --> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

A部分將佔據屏幕2/5。 B部分佔用屏幕的3/5,只有B部分可以滾動。