欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

前言:

今天在做項目時遇到了一個小問題

首先使用ViewPager顯示多個頁面,然后在每個頁面上使用Fragment顯示數(shù)據(jù),其中有一部分?jǐn)?shù)據(jù)是通過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>

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

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

android:descendantFocusability="blocksDescendants"

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

相關(guān)文章

  • Kotlin server多線程編程詳細(xì)講解

    Kotlin server多線程編程詳細(xì)講解

    這篇文章主要介紹了Kotlin server多線程編程,Service是實現(xiàn)程序后臺運(yùn)行的解決方案,適合執(zhí)行非交互,后臺預(yù)先的任務(wù),即使用戶打開其他應(yīng)用,Service也能夠正常運(yùn)行
    2023-01-01
  • Android自定義驗證碼輸入框的方法實例

    Android自定義驗證碼輸入框的方法實例

    這篇文章主要給大家介紹了關(guān)于Android自定義驗證碼輸入框的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),對各位Android開發(fā)者們具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2022-02-02
  • 淺談Android插件化

    淺談Android插件化

    插件化技術(shù)最初源于免安裝運(yùn)行 Apk的想法,這個免安裝的 Apk 就可以理解為插件,而支持插件的 app 我們一般叫 宿主,下面就跟著小編一起學(xué)習(xí)Android插件化吧,希望能幫助到你
    2021-09-09
  • Android實現(xiàn)截圖分享qq 微信功能

    Android實現(xiàn)截圖分享qq 微信功能

    在日常生活中,經(jīng)常用到qq,微信截圖分享功能,今天小編通過本文給大家介紹Android實現(xiàn)截圖分享qq 微信功能,具體實現(xiàn)代碼大家參考下本文
    2017-12-12
  • BroadcastReceiver靜態(tài)注冊案例詳解

    BroadcastReceiver靜態(tài)注冊案例詳解

    這篇文章主要為大家詳細(xì)介紹了BroadcastReceiver靜態(tài)注冊案例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • Android多種支付方式的實現(xiàn)示例

    Android多種支付方式的實現(xiàn)示例

    App的支付流程,添加多種支付方式,不同的支付方式,對應(yīng)的操作不一樣,有的會跳轉(zhuǎn)到一個新的webview,有的會調(diào)用系統(tǒng)瀏覽器,有的會進(jìn)去一個新的表單頁面,等等,本文就給大家詳細(xì)介紹一下Android 多種支付方式的優(yōu)雅實現(xiàn),需要的朋友可以參考下
    2023-09-09
  • Android開發(fā)之資源文件用法實例總結(jié)

    Android開發(fā)之資源文件用法實例總結(jié)

    這篇文章主要介紹了Android開發(fā)之資源文件用法,結(jié)合實例形式總結(jié)分析了Android開發(fā)過程中針對資源文件的常見操作技巧,需要的朋友可以參考下
    2016-02-02
  • 安卓輸入框被虛擬鍵盤擋住的問題(微信開發(fā))

    安卓輸入框被虛擬鍵盤擋住的問題(微信開發(fā))

    這篇文章主要介紹了安卓輸入框被虛擬鍵盤擋住的問題(微信開發(fā))的相關(guān)資料,需要的朋友可以參考下
    2016-04-04
  • Android RecyclerView實現(xiàn)點擊條目刪除

    Android RecyclerView實現(xiàn)點擊條目刪除

    這篇文章主要為大家詳細(xì)介紹了Android RecyclerView實現(xiàn)點擊條目刪除,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-11-11
  • Android實現(xiàn)局部模糊效果

    Android實現(xiàn)局部模糊效果

    這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)局部模糊效果,幫助大家實現(xiàn)模糊或者毛玻璃效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07

最新評論