国产探花免费观看_亚洲丰满少妇自慰呻吟_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開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 祁东县| 和平区| 墨竹工卡县| 盘山县| 灌云县| 九江市| 大兴区| 嵊州市| 会同县| 稻城县| 玛纳斯县| 平遥县| 渝中区| 濮阳市| 彭州市| 陆河县| 许昌县| 手游| 五指山市| 兰考县| 巴林右旗| 斗六市| 上林县| 洱源县| 张家港市| 兴城市| 康马县| 贞丰县| 彰化县| 安远县| 长沙县| 九江县| 柳林县| 鄂托克前旗| 屯留县| 永川市| 张掖市| 山东省| 宁陕县| 庄浪县| 图木舒克市|