Reputation: 970
I have a webview
inside Scrollview
.I need to have zoom control when tap on webview
but apparently it does not work when parent layout is scrollview
. what is the solution? is there any way to have zoom control in this situation?
here is my xml code:
<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>
Upvotes: 0
Views: 869
Reputation: 4335
Use,
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
and
Check if you don't have a ScrollView wrapping your Webview.
In my case that was the problem. It seems ScrollView gets in the way of the pinch gesture.
To fix it, just take your Webview outside the ScrollView.
Upvotes: 2