为什么 HorizontalScrollView 不工作 (Android)?
Why is HorizontalScrollView not working (Android)?
我不明白为什么水平滚动视图不工作,垂直滚动视图工作正常,有人可以解释一下吗?我在网上搜索了答案,但似乎没有任何效果,我已经尝试过嵌套的滚动视图和列表视图。我的想法是创建一个以垂直线性布局组织的测验,但有些问题有多个复选框答案,而且它不适合屏幕宽度,所以我尝试添加一个水平滚动视图,这样我就可以访问所有的复选框没有格式错误。
<ScrollView
xmlns:android="http://schemas.android.co...
xmlns:app="http://schemas.android.com/ap...
xmlns:tools="http://schemas.android.com/...
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.quiz....
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Textview> </TextView>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"~
android:scrollbars="horizontal"
android:nestedScrollingEnabled="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox><CheckBox/>
<LinearLayout/>
<HorizontalScrollView/>
<LinearLayout/>
<Scrollview/>
您可以将回收站视图添加到您的布局文件中
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_view"
xmlns:android="http://schemas.android.com/apk/res/android" />
在 java 文件中将其方向设置为水平
LinearLayoutManager LayoutManager = new LinearLayoutManager(this);
LayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
RecyclerView.setLayoutManager(LayoutManager);
我不明白为什么水平滚动视图不工作,垂直滚动视图工作正常,有人可以解释一下吗?我在网上搜索了答案,但似乎没有任何效果,我已经尝试过嵌套的滚动视图和列表视图。我的想法是创建一个以垂直线性布局组织的测验,但有些问题有多个复选框答案,而且它不适合屏幕宽度,所以我尝试添加一个水平滚动视图,这样我就可以访问所有的复选框没有格式错误。
<ScrollView
xmlns:android="http://schemas.android.co...
xmlns:app="http://schemas.android.com/ap...
xmlns:tools="http://schemas.android.com/...
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.quiz....
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Textview> </TextView>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"~
android:scrollbars="horizontal"
android:nestedScrollingEnabled="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox><CheckBox/>
<LinearLayout/>
<HorizontalScrollView/>
<LinearLayout/>
<Scrollview/>
您可以将回收站视图添加到您的布局文件中
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_view"
xmlns:android="http://schemas.android.com/apk/res/android" />
在 java 文件中将其方向设置为水平
LinearLayoutManager LayoutManager = new LinearLayoutManager(this);
LayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
RecyclerView.setLayoutManager(LayoutManager);