1

我有一個XML佈局如下。我有一個TExt視圖,然後是一些複選框,然後是一個按鈕。我已將所有複選框都包含在線性佈局中,併爲此設置了滾動視圖。「我無法在滾動後查看按鈕,我該怎麼辦?XML佈局 - 按鈕滾動後不可見

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 


    <TextView /> 

    <ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     android:orientation="vertical" > 

     <LinearLayout> 

      <CheckBox /> 

      <CheckBox /> 

      <CheckBox/> 

      <CheckBox/> 

      <CheckBox/> 

      <CheckBox/> 

      <CheckBox/> 

      <CheckBox/> 

      <CheckBox /> 

      <CheckBox/> 

      <CheckBox /> 
     </LinearLayout> 
    </ScrollView> 

    <Button 

    </Button> 

</LinearLayout> 
+1

您的問題標題和說明不符?奇怪 –

+0

對不起,早上5點我就要睡了。謝謝指出。 – chitranna

+0

晚安我親愛的朋友,睡得好。 –

回答

1

沒有爲滾動視圖 的條件應該只有一個滾動視圖childview 子視圖可能包含5個子的孩子,如果你想顯示你有使用視圖懷特按鈕查看

概念

<LinearLayout 
     <TextView 
    <ScrollView 
    <LinearLayout 
     <CheckBox 
     <CheckBox 
     <CheckBox 
     <CheckBox 
     . 



     <CheckBox 
    LinearLayout> 
    ScrollView> 
     <Button 
android:layout_weight="1" 

    LinearLayout > 
+0

這很好,但如果我這樣做,我會有一個問題。向下滾動時,我的按鈕將不可見。 另外我有很多複選框 – chitranna

+0

好吧,這意味着你需要一些在Android設計的做法。 – Sandy09

+0

是的,我從一個月左右開始做這件事 – chitranna

0

你有用戶的RelativeLayout或FrameLayout裏爲更好的解決方案.. 這是一個使用相對佈局

代碼
<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 


     <Button 
      android:id="@+id/relative_button" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
android:text="hello one" 
      > 
     </Button> 

     <ScrollView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_above="@id/relative_button" 
      > 

     <LinearLayout> 

       <CheckBox /> 

       <CheckBox /> 

       <CheckBox/> 

       <CheckBox/> 

       <CheckBox/> 

       <CheckBox/> 

       <CheckBox/> 

       <CheckBox/> 

       <CheckBox /> 

       <CheckBox/> 

       <CheckBox /> 
      </LinearLayout> 
     </ScrollView> 

    </RelativeLayout> 
0

請嘗試下面的代碼。您需要將按鈕對齊到底部,並將包含複選框的LinearLayout對齊按鈕。我試過這段代碼,它適用於我。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:text="ABC" /> 

    <ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/textView" 
     android:layout_above="@+id/button" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" > 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <CheckBox 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 
     </LinearLayout> 
    </ScrollView> 

    <Button 
     android:id="@+id/button" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</RelativeLayout>