国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android 中ViewPager中使用WebView的注意事項

2019-10-22 18:28:24
字體:
來源:轉載
供稿:網友

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開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 贡山| 临武县| 万全县| 婺源县| 修武县| 吴忠市| 安乡县| 博爱县| 永善县| 扎兰屯市| 巫溪县| 都兰县| 米脂县| 焉耆| 镇平县| 道真| 蒲城县| 广元市| 庐江县| 桓仁| 孝昌县| 乌兰县| 鸡西市| 洪江市| 富宁县| 东乡| 营口市| 玉山县| 余庆县| 富顺县| 民乐县| 大荔县| 沈阳市| 鄂温| 蚌埠市| 涡阳县| 正定县| 得荣县| 怀集县| 五峰| 黄大仙区|