我有webview
在Scrollview
的內部。我需要在點擊webview
時有縮放控制,但顯然在父配置爲scrollview
時它不起作用。解決辦法是什麼?有什麼辦法可以在這種情況下進行縮放控制嗎?在滾動視圖內啓用webview縮放控制
這裏是我的XML代碼:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="380dp">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@color/item_bg"
android:orientation="vertical">
<TextView
android:id="@+id/tv_title_news"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingBottom="20dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="20dp"
android:shadowColor="#000"
android:shadowDx="1"
android:shadowDy="3"
android:shadowRadius="5"
android:text="Medium"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFF" />
</LinearLayout>
<ImageView
android:id="@+id/img_news_pic"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<ir.whc.news.views.CircularNetworkImageView
android:id="@+id/img_circleThumbnail1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="33dp"
android:layout_marginLeft="10dp">
</ir.whc.news.views.CircularNetworkImageView>
<TextView
android:id="@+id/tv_cnt_eye"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/linearLayout1"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/fontAwesomeText1"
android:paddingLeft="6dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFF"
android:textSize="11dp" />
<com.beardedhen.androidbootstrap.AwesomeTextView
android:id="@+id/fontAwesomeText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/linearLayout1"
android:layout_marginBottom="10dp"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/img_circleThumbnail1"
android:textColor="#FFF"
app:fontAwesomeIcon="fa_eye"
/>
<com.beardedhen.androidbootstrap.AwesomeTextView
android:id="@+id/fontAwesomeText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/fontAwesomeText1"
android:layout_marginLeft="16dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/img_circleThumbnail1"
android:textColor="#000"
app:fontAwesomeIcon="fa_clock_o" />
<TextView
android:id="@+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/fontAwesomeText1"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/fontAwesomeText2"
android:paddingLeft="6dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000"
android:textSize="13dp" />
</RelativeLayout>
<TextView
android:id="@+id/tv_sum_news"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lineSpacingExtra="15dp"
android:paddingBottom="20dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/tv_desc_news"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />
<WebView
android:scrollbars="vertical"
android:clickable="true"
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAlignment="center"
android:textDirection="rtl" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:background="@drawable/grad"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="right">
<ImageView
android:id="@+id/image_bookmark_content"
android:layout_width="@dimen/bookmerk_content_size"
android:layout_height="@dimen/bookmerk_content_size"
android:src="@drawable/ic_bookmark_normal"/>
<ImageView
android:id="@+id/image_share_content"
android:layout_width="@dimen/bookmerk_content_size"
android:layout_height="@dimen/bookmerk_content_size"
android:src="@drawable/ic_share"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:name="ir.whc.news.activity.FragmentDrawer"
android:layout_width="@dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
但爲什麼你有webview內滾動視圖? –
,因爲我需要滾動我的佈局 – serenei
你可以試試這個:'webview.getSettings()。setBuiltInZoomControls(true); webview.getSettings()。setDisplayZoomControls(false);' –