最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android 中ViewPager中使用WebView的注意事項(xiàng)

 更新時(shí)間:2017年09月06日 11:44:48   作者:Danny_姜  
這篇文章主要介紹了Android 中ViewPager中使用WebView的注意事項(xiàng)的相關(guān)資料,希望通過(guò)本文大家在使用過(guò)程中遇到這樣的問(wèn)題解決,需要的朋友可以參考下

Android 中ViewPager中使用WebView的注意事項(xiàng)

前言:

今天在做項(xiàng)目時(shí)遇到了一個(gè)小問(wèn)題

首先使用ViewPager顯示多個(gè)頁(yè)面,然后在每個(gè)頁(yè)面上使用Fragment顯示數(shù)據(jù),其中有一部分?jǐn)?shù)據(jù)是通過(guò)WebView加載的Html標(biāo)簽。

具體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>

問(wèn)題是當(dāng)數(shù)據(jù)加載完畢之后,WebView會(huì)自動(dòng)移動(dòng)到頁(yè)面的最頂端,如果用戶想查看處于WebView上方的TextView內(nèi)容則必須手動(dòng)將頁(yè)面往下拉

解決以上問(wèn)題可以在Scrollview中所使用的LinearLayout添加如下屬性:

android:descendantFocusability="blocksDescendants"

如有疑問(wèn)請(qǐng)留言或到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論

孟村| 当阳市| 石嘴山市| 盐池县| 柳江县| 宝兴县| 尚志市| 英山县| 叙永县| 宜章县| 沂南县| 凌云县| 梅州市| 朝阳县| 五河县| 伊宁市| 江油市| 江油市| 仲巴县| 万州区| 凌源市| 铜鼓县| 永城市| 泰来县| 堆龙德庆县| 武强县| 津市市| 宁武县| 临海市| 芦山县| 洞口县| 普陀区| 浦北县| 福建省| 施秉县| 东辽县| 玉环县| 疏附县| 湾仔区| 同江市| 望谟县|