我有一个布局有许多字段,我希望添加滚动条为水平和垂直layout.But垂直滚动是工作的水平滚动不工作。我已经在程序中动态加载文本字段,并添加与web服务的字段。
我的活动
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LayoutScroll"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="horizontal|vertical" >
<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="10dp"
    android:layout_marginTop="30dp"
    android:gravity="fill|fill_horizontal"
    android:orientation="vertical" >
      <TableRow
          android:id="@+id/Row_User_Deletion"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="#DF0101"
          android:gravity="center" >
         <TextView
             android:id="@+id/user_creation_id"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/txt_delete_user_userDeletion"
             android:textColor="@color/white"
             android:textSize="15dp" />
     </TableRow>
      <TableRow
          android:id="@+id/RowUserType"
          android:layout_width="match_parent"
          android:layout_height="45dp"
          android:layout_marginTop="10dp" >
          <TextView
              android:id="@+id/txt_delete_user_selectuserType"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="5dp"
              android:text="@string/txt_delete_user_selectuserType"
              android:textColor="#424242" />
          <Spinner
              android:id="@+id/spin_delete_userType"
              android:layout_width="120dp"
              android:layout_height="50dp"
              android:layout_marginBottom="5dp"
              android:entries="@array/utype" />
          <Button
              android:id="@+id/btn_spinner_user_search_select"
              style="?android:attr/buttonStyleSmall"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="25dp"
              android:layout_marginTop="5dp"
              android:background="@drawable/redbtn"
              android:text="@string/btn_delete_user_search_user" />
      </TableRow>
    <TableRow
        android:id="@+id/deleteUserRow"
        android:layout_width="match_parent"
        android:layout_height="34dp"
        android:layout_marginTop="10dp"
        android:gravity="fill" >
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/txt_user_creation_userId"
            android:textColor="#424242" />
        <EditText
            android:id="@+id/txt_user_delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:ems="10" >
            <requestFocus />
        </EditText>
        <Button
            android:id="@+id/button1"
            android:layout_width="55dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:background="@drawable/redbtn"
            android:text="@string/btn_delete_user_search_user" />
        </TableRow>
         <TableLayout
             android:id="@+id/delete_userDetails_Table"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="5dp"
             android:orientation="vertical"
             android:stretchColumns="*" >
            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="5dp"
                android:background="@color/red" >
                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:text="@string/txt_delete_user_select"
                    android:textColor="@color/white" />
                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:text="@string/txt_user_creation_userId"
                    android:textColor="@color/white" />
                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:text="@string/txt_user_creation_userName"
                    android:textColor="@color/white" />
                <TextView
                    android:id="@+id/textView5"
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:text="@string/txt_delete_user_UserRole"
                    android:textColor="@color/white" />
                <TextView
                    android:id="@+id/textView5"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/txt_componentmaster_createdDate"
                    android:textColor="@color/white" />
                <TextView
                    android:id="@+id/textView5"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/txt_componentmaster_createdBy"
                    android:textColor="@color/white" />
            </TableRow>
        </TableLayout>
    </LinearLayout>
</ScrollView>ImageView

发布于 2012-12-22 11:39:26
请记住,您想要水平滚动的视图必须将LinearLayout作为父视图,然后只有您可以设置该布局之间的HorizontalScrollView。
并将一个HorizontalScrollView作为这两个LinearLayout的父对象。
希望这能对你有所帮助。
示例:
<HORIZONTAL_VIEW ... >
 <!-- Your First Layout -->
 <LinearLayout ... >
 </LinearLayout>
 <!-- Your Second Layout -->
 <LinearLayout ... >
 </LinearLayout>
 </HORIZONTAL_VIEW ... >希望你明白我的意思。
您可以随意查询任何问题。:)
https://stackoverflow.com/questions/13990732
复制相似问题