java - 滚动视图在 OS 4.1.2 上不起作用
问题描述
我在布局中添加了滚动视图,滚动视图具有匹配父级的高度和宽度属性,fillViewPort 也适用于滚动视图,它在其他设备中工作但在 android OS 4.1.2 中不工作。
布局 :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:background="@android:color/white"
android:layout_height="match_parent">
<!-- <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!– <ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:scaleType="fitXY"
android:src="@drawable/page"/>–>
</RelativeLayout>-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="8">
<TextView
android:id="@+id/main_welcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dimen_20dp"
android:text="@string/welcome"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<GridView
android:id="@+id/gridviewMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dimen_40dp"
android:layout_marginLeft="@dimen/dimen_40dp"
android:layout_marginRight="@dimen/dimen_40dp"
android:columnWidth="80dp"
android:horizontalSpacing="@dimen/dimen_10dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"></GridView>
</LinearLayout>
</ScrollView>
<TextView
android:id="@+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:text="For Any Queries Related To Mobile App Click On Service Request"
android:textAlignment="center" />
</RelativeLayout>
这可能是什么原因?所有其他滚动视图都在同一设备上工作,只是不能在这个屏幕上工作。
请帮忙。。谢谢。。
解决方案
尝试改用 nestedScrollView
<nestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="8">
<TextView
android:id="@+id/main_welcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dimen_20dp"
android:text="@string/welcome"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<GridView
android:id="@+id/gridviewMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dimen_40dp"
android:layout_marginLeft="@dimen/dimen_40dp"
android:layout_marginRight="@dimen/dimen_40dp"
android:columnWidth="80dp"
android:horizontalSpacing="@dimen/dimen_10dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"></GridView>
</LinearLayout>
</nestedScrollView>
推荐阅读
- postgresql - 如何使用 postico 之类的 GUI 客户端从我的家庭操作系统连接到 postgres?
- java - 如果值为空/空或某些特定字符串,如何检查 JSP 变量并隐藏?
- python - 使用 edx 在 Windows 服务器 2012 操作系统上具有活动目录的 SSO。
- android - android - 改造 2 - 无法读取 json 数组并解析它
- kotlin - 设计选项卡中的 Android Studio 错误
- javascript - 如何从数组中给 div 随机背景颜色
- android - 如何在意图的帮助下打开活动托管的第 n 个片段?
- c# - 如何拆分具有逗号和空格组合字符的文本?
- apache-spark - 有没有办法使用jobtracker或spark application master确认我提交的spark作业是yarn-client还是yarn-cluster?
- ios - 如何在 Objective-C 和 Swift 中实现“didSelectButtonInCellAtIndexPath:”?