Reputation:
I am using webview in my layout which is occupying top half of the screen. Other content of data is coming in down half screen. Data is huge so scroll is coming for that but problem is only down half portion is scrolling and top half portion where is created webview is not scrolling. I want to stick that webview to top of the screen so it will also scroll and scroll I can see new data in full screen.
My Layout code:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/navMainLayout">
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/right_menu"
android:id="@+id/drawerClickBtn"
android:padding="2dp"
android:background="@android:color/white"
android:scaleType="fitXY"/>
<View
android:layout_width="40dp"
android:layout_height="120dp"
android:background="@android:color/white"
android:layout_below="@+id/drawerClickBtn" />
<WebView
android:layout_width="match_parent"
android:layout_height="160dp"
android:id="@+id/qblebelId"
android:gravity="center|left"
android:layout_toRightOf="@+id/drawerClickBtn"
android:layout_alignBaseline="@+id/drawerClickBtn"
android:textColor="@color/AppThemeColor"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
android:text="Question Bank"/>
<ListView
android:id="@+id/expertAnswerlistId"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:padding="10dp"
android:animationCache="false"
android:cacheColorHint="@android:color/transparent"
android:layout_below="@+id/qblebelId"
android:divider="@null"
android:dividerHeight="10dp"
android:listSelector="@android:color/transparent"
android:scrollingCache="false"
android:fadeScrollbars="false"
android:smoothScrollbar="true"
android:longClickable="false"
android:scrollbars="none"
android:descendantFocusability="blocksDescendants" />
</RelativeLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/navDrawerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:orientation="vertical" >
<include
android:id="@+id/toolbar"
layout="@layout/tool_bar_expand"/>
<ExpandableListView
android:id="@+id/nav_left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:longClickable="false"
android:groupIndicator="@null" >
</ExpandableListView>
</LinearLayout>
Upvotes: 1
Views: 2492
Reputation: 870
May be help you try it
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/navMainLayout"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/right_menu"
android:id="@+id/drawerClickBtn"
android:padding="2dp"
android:background="@android:color/white"
android:scaleType="fitXY"/>
<View
android:layout_width="40dp"
android:layout_height="120dp"
android:background="@android:color/white"
android:layout_below="@+id/drawerClickBtn" />
<WebView
android:layout_width="match_parent"
android:layout_height="160dp"
android:id="@+id/qblebelId"
android:gravity="center|left"
android:layout_toRightOf="@+id/drawerClickBtn"
android:layout_alignBaseline="@+id/drawerClickBtn"
android:textColor="@color/AppThemeColor"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"
android:text="Question Bank"/>
<ListView
android:id="@+id/expertAnswerlistId"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:padding="10dp"
android:animationCache="false"
android:cacheColorHint="@android:color/transparent"
android:layout_below="@+id/qblebelId"
android:divider="@null"
android:dividerHeight="10dp"
android:listSelector="@android:color/transparent"
android:scrollingCache="false"
android:fadeScrollbars="false"
android:smoothScrollbar="true"
android:longClickable="false"
android:scrollbars="none"
android:descendantFocusability="blocksDescendants" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/navDrawerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:orientation="vertical" >
<include
android:id="@+id/toolbar"
layout="@layout/tool_bar_expand"/>
<ExpandableListView
android:id="@+id/nav_left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:longClickable="false"
android:groupIndicator="@null" >
</ExpandableListView>
</LinearLayout>
</RelativeLayout>
Upvotes: 1
Reputation: 560
This might be helpful to you:
WebView v = (WebView) findViewById(R.id.webview);
v.setVerticalScrollBarEnabled(true);
v.setHorizontalScrollBarEnabled(true);
Upvotes: 2
Reputation: 3212
Use
android:layout_width="wrap_content"
android:layout_height="wrap_content"
instead of
android:layout_width="match_parent"
android:layout_height="160dp"
Upvotes: 0