Android 如何使用滚动拇指使屏幕上下滚动?
我是android开发新手。有人能帮我解决这个问题吗? 每当我试图向下移动滚动条时,整个屏幕都会向上移动。 我创建的XML如下所示Android 如何使用滚动拇指使屏幕上下滚动?,android,gridview,scrollbar,Android,Gridview,Scrollbar,我是android开发新手。有人能帮我解决这个问题吗? 每当我试图向下移动滚动条时,整个屏幕都会向上移动。 我创建的XML如下所示 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="matc
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/backButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:textAppearance="@style/TextAppearance.AppCompat.Button" />
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="190dp"
android:fadeScrollbars="false"
android:fitsSystemWindows="true"
android:gravity="center"
android:horizontalSpacing="0dp"
android:numColumns="2"
android:scrollbarSize="20dp"
android:scrollbarStyle="outsideInset"
android:scrollbarThumbVertical="@drawable/scrollbar_vertical_thumb"
android:scrollbarTrackVertical="@drawable/scrollbar_vertical_track"
android:scrollbars="vertical"
android:stretchMode="columnWidth"
android:verticalSpacing="0dp"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:fastScrollAlwaysVisible="false"
android:fastScrollEnabled="false"/>
</LinearLayout>
您已将LinearLayout用作显示视图的容器。如果没有在其中定义方向,那么默认情况下它采用“水平”方向。在您的情况下,您必须将方向设置为垂直方向 改变你的线性布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
详情如下:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
说明android:方向为“垂直”