gpt4 book ai didi

Android水平 ScrollView

转载 作者:行者123 更新时间:2023-11-29 18:04:46 25 4
gpt4 key购买 nike

我有一个包含很多字段的布局,我希望为水平和垂直布局添加滚动条。但是垂直滚动正在工作,水平滚动不起作用。我在程序中动态加载了文本字段,并使用 Web 服务添加了字段.

我的 Activity

<?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

enter image description here

最佳答案

请记住,您要水平滚动的 View 必须将 LinearLayout 作为父 View ,然后您才能在该布局之间设置 Horizo​​ntalScrollView。

并将一个 Horizo​​ntalScrollView 作为这两个 LinearLayout 的父级。

希望对您有所帮助。

示例:

<HORIZONTAL_VIEW ... >

<!-- Your First Layout -->
<LinearLayout ... >

</LinearLayout>

<!-- Your Second Layout -->
<LinearLayout ... >

</LinearLayout>

</HORIZONTAL_VIEW ... >

希望你明白我的意思。

欢迎咨询。 :)

关于Android水平 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13990732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com