Android 中ViewPager中使用WebView的注意事項
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ū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
- Android Studio 導(dǎo)入開源項目的正確姿勢及注意事項
- Android Studio3.0升級后使用注意事項及解決方法
- Android 程序執(zhí)行Linux命令的解決方法及注意事項
- 將Eclipse工程轉(zhuǎn)Android Studio工程的步驟與注意事項
- AndroidStudio升級到3.0的新特性和注意事項小結(jié)
- 詳解Android Service 使用時的注意事項
- Android TimerTask 的簡單應(yīng)用及注意事項
- Android 如何使用log4j及注意事項
- Android集成百度地圖開發(fā)流程和注意事項
- Android onNewIntent()觸發(fā)機(jī)制及注意事項
- Android Studio添加第三方庫的注意事項
- Android 程序申請權(quán)限注意事項
- Android Service自啟動注意事項分析
- 關(guān)于Android WebView的loadData方法的注意事項分析
- Android NDK中socket的用法以及注意事項分析
- Android生存指南之:開發(fā)中的注意事項
- Android 編程下字庫的使用及注意事項
- 60條Android開發(fā)注意事項與經(jīng)驗總結(jié)
相關(guān)文章
android 動態(tài)控制狀態(tài)欄顯示和隱藏的方法實例
這篇文章主要介紹了2013-12-12
Android編程實現(xiàn)狀態(tài)保存的方法分析
這篇文章主要介紹了Android編程實現(xiàn)狀態(tài)保存的方法,結(jié)合實例形式分析了Android狀態(tài)保存的原理、實現(xiàn)方法與相關(guān)注意事項,需要的朋友可以參考下2017-08-08
詳談自定義View之GridView單選 金額選擇Layout-ChooseMoneyLayout
下面小編就為大家?guī)硪黄斦勛远xView之GridView單選 金額選擇Layout-ChooseMoneyLayout。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05
Android編程開發(fā)實現(xiàn)帶進(jìn)度條和百分比的多線程下載
這篇文章主要介紹了Android編程開發(fā)實現(xiàn)帶進(jìn)度條和百分比的多線程下載,總結(jié)了前面關(guān)于Java多線程下載的技巧,實例分析了Android實現(xiàn)帶百分比和進(jìn)度條的多線程下載技巧,需要的朋友可以參考下2015-12-12
Android 實現(xiàn)圓圈擴(kuò)散水波動畫效果兩種方法
這篇文章主要介紹了Android 實現(xiàn)圓圈擴(kuò)散水波動畫效果兩種方法,需要的朋友可以參考下2018-05-05
基于Android studio3.6的JNI教程之ncnn之語義分割ENet
這篇文章主要介紹了基于Android studio3.6的JNI教程之ncnn之語義分割ENet的相關(guān)知識,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值 ,需要的朋友可以參考下2020-03-03
Android開發(fā)中判斷手機(jī)是否安裝了QQ或者微信
這篇文章主要介紹了Android開發(fā)中判斷手機(jī)是否安裝了QQ或者微信的相關(guān)資料,需要的朋友可以參考下2017-01-01
android的RecyclerView實現(xiàn)拖拽排序和側(cè)滑刪除示例
在平時開發(fā)應(yīng)用的時候,經(jīng)常會遇到列表排序、滑動刪除的需求。這篇文章主要介紹了android的RecyclerView實現(xiàn)拖拽排序和側(cè)滑刪除示例,有興趣的可以了解一下。2017-02-02

