人教版小学语文,钮枯禄穗儿,安庆师范学院校历
android 中viewpager中使用webview的注意事项
前言:
今天在做项目时遇到了一个小问题
首先使用viewpager显示多个页面,然后在每个页面上使用fragment显示数据,其中有一部分数据是通过webview加载的html标签。
具体xml布局如下
<?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/background" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:id="@+id/article_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginright="10dp" android:layout_marginleft="10dp" android:layout_margintop="10dp" android:layout_marginbottom="2dp" android:text="some title" android:textappearance="?android:attr/textappearancelarge" android:textcolor="@color/article_title" android:textstyle="bold" /> <linearlayout android:id="@+id/ll_seperator" android:layout_width="fill_parent" android:layout_height="1dp" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:layout_margintop="5dp" android:layout_marginbottom="5dp" android:background="@color/text" android:orientation="horizontal" > </linearlayout> <webview android:id="@+id/article_content" android:layout_width="match_parent" android:layout_marginright="10dp" android:layout_marginleft="10dp" android:layout_height="wrap_content" /> <textview android:id="@+id/article_link" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginbottom="5dp" android:layout_margintop="5dp" android:layout_marginright="10dp" android:layout_marginleft="10dp" android:text="view full article" android:textcolor="@color/article_title" android:textstyle="bold" /> </linearlayout> </scrollview>
问题是当数据加载完毕之后,webview会自动移动到页面的最顶端,如果用户想查看处于webview上方的textview内容则必须手动将页面往下拉
解决以上问题可以在scrollview中所使用的linearlayout添加如下属性:
android:descendantfocusability="blocksdescendants"
如有疑问请留言或到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Android studio开发小型对话机器人app(实例代码)
Android通过Java sdk的方式接入OpenCv的方法
Android 通过cmake的方式接入opencv的方法步骤
Android Studio finish()方法的使用与解决app点击“返回”(直接退出)
Android 进度条 ProgressBar的实现代码(隐藏、出现、加载进度)
网友评论