Android 中ViewPager中使用WebView的注意事項(xiàng)
Android 中ViewPager中使用WebView的注意事項(xiàng)
前言:
今天在做項(xiàng)目時(shí)遇到了一個(gè)小問題
首先使用ViewPager顯示多個(gè)頁面,然后在每個(gè)頁面上使用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ū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
- Android Studio 導(dǎo)入開源項(xiàng)目的正確姿勢及注意事項(xiàng)
- Android Studio3.0升級后使用注意事項(xiàng)及解決方法
- Android 程序執(zhí)行Linux命令的解決方法及注意事項(xiàng)
- 將Eclipse工程轉(zhuǎn)Android Studio工程的步驟與注意事項(xiàng)
- AndroidStudio升級到3.0的新特性和注意事項(xiàng)小結(jié)
- 詳解Android Service 使用時(shí)的注意事項(xiàng)
- Android TimerTask 的簡單應(yīng)用及注意事項(xiàng)
- Android 如何使用log4j及注意事項(xiàng)
- Android集成百度地圖開發(fā)流程和注意事項(xiàng)
- Android onNewIntent()觸發(fā)機(jī)制及注意事項(xiàng)
- Android Studio添加第三方庫的注意事項(xiàng)
- Android 程序申請權(quán)限注意事項(xiàng)
- Android Service自啟動注意事項(xiàng)分析
- 關(guān)于Android WebView的loadData方法的注意事項(xiàng)分析
- Android NDK中socket的用法以及注意事項(xiàng)分析
- Android生存指南之:開發(fā)中的注意事項(xiàng)
- Android 編程下字庫的使用及注意事項(xiàng)
- 60條Android開發(fā)注意事項(xiàng)與經(jīng)驗(yàn)總結(jié)
相關(guān)文章
Android自定義驗(yàn)證碼輸入框的方法實(shí)例
這篇文章主要給大家介紹了關(guān)于Android自定義驗(yàn)證碼輸入框的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對各位Android開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2022-02-02
Android實(shí)現(xiàn)截圖分享qq 微信功能
在日常生活中,經(jīng)常用到qq,微信截圖分享功能,今天小編通過本文給大家介紹Android實(shí)現(xiàn)截圖分享qq 微信功能,具體實(shí)現(xiàn)代碼大家參考下本文2017-12-12
BroadcastReceiver靜態(tài)注冊案例詳解
這篇文章主要為大家詳細(xì)介紹了BroadcastReceiver靜態(tài)注冊案例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08
Android開發(fā)之資源文件用法實(shí)例總結(jié)
這篇文章主要介紹了Android開發(fā)之資源文件用法,結(jié)合實(shí)例形式總結(jié)分析了Android開發(fā)過程中針對資源文件的常見操作技巧,需要的朋友可以參考下2016-02-02
Android RecyclerView實(shí)現(xiàn)點(diǎn)擊條目刪除
這篇文章主要為大家詳細(xì)介紹了Android RecyclerView實(shí)現(xiàn)點(diǎn)擊條目刪除,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11

