2014-03-28 56 views
0

我有含有tablelayout和相對佈局打開自動滾動

相對佈局被設置作爲頁腳 內部表格的佈局I位置多個其它組件(textviews,editboxes,按鈕)

線性佈局

,我想這個表格佈局有一個滾動條

我設置其屬性有一個垂直滾動條,但已經不起作用

這裏是我的佈局

<LinearLayout xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:scrollbarStyle="insideOverlay" 
    android:scrollbars="vertical" 
    tools:context="com.teo.cuteoeditor.PreferenceActivity$PlaceholderFragment" xmlns:android="http://schemas.android.com/apk/res/android"> 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:scrollbarStyle="insideOverlay" 
     android:scrollbars="vertical" > 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" > 

      <include 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       layout="@layout/pref_title_layout" 
       android:scrollbarStyle="insideOverlay" 
       android:scrollbars="vertical" /> 

      </TableRow> 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="1px" 
      android:background="#42424242" /> 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" > 

      <include 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       layout="@layout/pref_desc_layout" 
       android:scrollbars="vertical" /> 

      </TableRow> 
     <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="1px" 
     android:background="#42424242" /> 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" > 

      <include 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       layout="@layout/pref_location_layout" 
       android:scrollbarStyle="insideOverlay" /> 

      </TableRow> 
     <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="1px" 
     android:background="#42424242" /> 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" > 

      <include 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       layout="@layout/pref_time_to_from" /> 
     </TableRow> 
     <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="1px" 
     android:background="#42424242" /> 

     <TableRow 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" > 

      <include 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       layout="@layout/pref_reminder" /> 
     </TableRow> 
    </TableLayout> 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="1px" 
     android:background="#42424242" /> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom|center_vertical|center_horizontal" > 

     <Button 
      android:id="@+id/pref_save_btn" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="100dp" 
      android:layout_height="35dp" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:layout_centerInParent="false" 
      android:text="@string/pref_cancel" /> 

     <Button 
      android:id="@+id/pref_cancel_btn" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_width="100dp" 
      android:layout_height="35dp" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="false" 
      android:layout_centerInParent="false" 
      android:layout_centerVertical="false" 
      android:layout_marginRight="10dp" 
      android:text="@string/pref_save" /> 

    </RelativeLayout> 

</LinearLayout> 

看那3編輯框,如果這個活動的資源被調用,我的光標集中在第三編輯框,機器人自動鍵盤顯示出來,它涵蓋了我的第三個編輯框。屏幕應該拉起來讓我知道我的光標在哪裏,以便我可以在框中輸入,對吧?

回答

0

包住整個事情:

<ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scrollbars="none" 
     android:layout_weight="1"> 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 


     </LinearLayout> 
    </ScrollView> 

還檢查了:: How to scroll table layout in horizontal and vertical in android