Android中ViewPager如何使用WebView-創(chuàng)新互聯(lián)

小編給大家分享一下Android中ViewPager如何使用WebView,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)建站為客戶提供專業(yè)的網(wǎng)站設(shè)計制作、成都網(wǎng)站建設(shè)、程序、域名、空間一條龍服務(wù),提供基于WEB的系統(tǒng)開發(fā). 服務(wù)項目涵蓋了網(wǎng)頁設(shè)計、網(wǎng)站程序開發(fā)、WEB系統(tǒng)開發(fā)、微信二次開發(fā)、手機網(wǎng)站制作等網(wǎng)站方面業(yè)務(wù)。

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"

以上是“Android中ViewPager如何使用WebView”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

新聞標(biāo)題:Android中ViewPager如何使用WebView-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://muchs.cn/article36/ijpsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、建站公司、App設(shè)計軟件開發(fā)、虛擬主機、移動網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名