2012-08-06 110 views
0

以下是android佈局。滾動視圖問題

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/svb" 
    android:layout_width="fill_parent" 
    android:layout_height="450dp" 

    android:isScrollContainer="true" 
    android:scrollbarAlwaysDrawVerticalTrack="true" 
    android:scrollbarStyle="outsideInset" 
    android:scrollbars="vertical"> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/grid_view" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:numColumns="2" 


android:gravity="center_horizontal" 
android:layout_gravity="center_horizontal" 
android:stretchMode="columnWidth" 
> 
</GridView> 



<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:gravity="center" 
android:id="@+id/rl2" 
> 
<RelativeLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/rl3" 
> 
<ImageView 
    android:id="@+id/total" 
    android:layout_width="30dp" 
    android:layout_height="30dp" 
    android:src="@drawable/total"   
    /> 
<TextView 
     android:id="@+id/totalscore" 
     android:layout_width ="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_toRightOf="@id/total" 
     android:paddingLeft="5dp" 
     android:text="" /> 
</RelativeLayout> 
</RelativeLayout> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
    android:orientation="vertical" 
android:id="@+id/rl4" 

> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:gravity="bottom" 
    > 
<Button 
      android:id="@+id/comment" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="RATE THIS APP" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" 
      android:layout_alignParentBottom="true" 


      /> 
</LinearLayout> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:gravity="center_vertical" 
    > 

<Button 
      android:id="@+id/paid" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="BUY AD FREE VERSION" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" 
      android:layout_centerVertical="true" 


      /> 

    </LinearLayout> 

    </LinearLayout> 



    </LinearLayout> 
    </ScrollView> 

我想要滾動包含整個佈局,但它只覆蓋gridview。只顯示gridview的一個項目,並查看其他我必須滾動的項目。 gridview下方的視圖始終顯示。如何糾正這一點。

回答

1

嘗試設置的android:剛剛滾動視圖

+0

現在,所有的意見都可見,但沒有scrollbar.bottom兩個按鈕被擠壓到屏幕,而不是一個可見的滾動條 – 2012-08-06 17:43:40

0
try this 

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="450dp"> <----replace this with wrap_content 

<LinearLayout ...>   

    // ADD ALL OTHER LAYOUT HERE 

     <TextView 
       android:id="@+id/totalscore" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toRightOf="@+id/total" <---- you forget PLUS sign here 
       android:paddingLeft="5dp" 
       android:text="" /> 

</LinearLayout> 
</ScrollView> 
+0

流出低於這個扭曲了的示例代碼佈局。 gridview下方的按鈕不可見。在gridview中只有3行是可見的,其他行必須滾動 – 2012-08-06 17:41:34

+0

看到我編輯的答案正確這個'android:layout_toRightOf =「@ + id/total」' – MAC 2012-08-06 17:51:31

+0

沒有改變結果。 – 2012-08-06 18:04:20

0

您可以滾動型內使用Tablelayout後在第一的LinearLayout layout_height = 「WRAP_CONTENT」。這裏是工作

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ScrollView01" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textSize="20sp"> 

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/tableLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/back" 
     android:scrollbars="vertical" 
     android:textSize="20sp"> 
     <!--Month Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Select Month" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <Spinner 
       android:id="@+id/spinner" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <Spinner 
       android:id="@+id/spinneryr" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 
     </TableRow> 
     <!--Field1 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/ERYTHROCYTE" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 


      <EditText 
       android:id="@+id/ERYTHROCYTE" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 

       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field2 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/HAEMOGLOBIN" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/HAEMOGLOBIN" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 

       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field3 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/PCV" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/PCV" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 

       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field4 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow5" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/RDW" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/RDW" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 

       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field5 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow6" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/MCV" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/MCV" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 
       android:gravity="center" 
       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field6 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow7" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/MCH" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/MCH" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 

       android:inputType="numberDecimal" /> 
     </TableRow> 

     <!--Field7 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow8" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/MCHC" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/MCHC" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 
       android:gravity="center" 
       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field8 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow9" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/LEUCOCYTECOUNT" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/LEUCOCYTECOUNT" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 
       android:gravity="center" 
       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field9 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow10" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/PLATELETS" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/PLATELETS" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 
       android:gravity="center" 
       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field10 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow11" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/NEUTROPHILS" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/NEUTROPHILS" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 
       android:gravity="center" 
       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field11 Combo Box--> 
     <TableRow 
      android:id="@+id/tableRow12" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/EOSINOPHILS" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/EOSINOPHILS" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 
       android:gravity="center" 
       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!--Field12 Combo Box--> 

     <TableRow 
      android:id="@+id/tableRow13" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:padding="20sp"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/LYMPHOCYTES" 
       android:textColor="#0c0b0b" 
       android:textSize="20sp" /> 

      <EditText 
       android:id="@+id/LYMPHOCYTES" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/back" 
       android:gravity="center" 
       android:inputType="numberDecimal" /> 
     </TableRow> 
     <!-- Button :Start here--> 
     <TableRow 
      android:id="@+id/tableRow14" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="20sp"> 

      <Button 
       android:id="@+id/btnAdd" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/add" /> 
      <Button 
       android:id="@+id/btnViewAll" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/view_all" /> 
     </TableRow> 

      <!--<Button 
       android:id="@+id/btnDelete" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/delete" /> 

      <Button 
       android:id="@+id/btnShowInfo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/show_info" /> 
     </TableRow>--> 

<!--  <TableRow 
      android:id="@+id/tableRow15" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:padding="20sp"> 

      <Button 
       android:id="@+id/btnModify" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/modify" /> 

      <Button 
       android:id="@+id/btnView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/view" /> 




      <Button 
      android:id="@+id/btnShowInfo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/show_info" > 
     </TableRow--> 

     <TextView 
      android:id="@+id/tvValues" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:textSize="20sp" /> 
    </TableLayout> 
</ScrollView> 

enter image description here