Is it possible to set scrollbar below a toolbar in Android? I am trying out the scrollbarView I have toolbar attached to my Layout something like this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/layoutcolor_background"
android:orientation="vertical"
tools:ignore="ContentDescription,RtlHardcoded,NestedWeights">
<include
android:id="@+id/toolbar"
layout="@layout/main_toolbar" />
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_dropshadow" />
<LinearLayout
android:id="@+id/aandcID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight=".50"
android:baselineAligned="false"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/alayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight=".50"
android:background="@color/layoutbackgroudforrow"
android:gravity="center">
<ImageView
android:id="@+id/aimage"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:paddingBottom="3dp"
android:paddingTop="5dp"
android:src="@drawable/acc" />
<TextView
android:id="@+id/aType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/aimage"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:gravity="center"
android:paddingLeft="2dp"
android:singleLine="true"
android:text="Deposit"
android:textColor="@color/blackText"
android:textSize="18sp"
android:textStyle="bold"
tools:ignore="RtlSymmetry,RtlHardcoded,HardcodedText" />
<TextView
android:id="@+id/anumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/aType"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:gravity="center"
android:paddingLeft="2dp"
android:singleLine="true"
android:text="12345678901234567890"
android:textColor="@color/blackText"
android:textSize="18sp"
tools:ignore="RtlSymmetry,RtlHardcoded,HardcodedText" />
<ImageView
android:id="@+id/rupeeIcon"
android:layout_width="12dp"
android:layout_height="14dp"
android:layout_below="@+id/anumber"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:layout_toLeftOf="@+id/accatext"
android:background="@drawable/rupees_symbol"
android:paddingBottom="2dp"
android:visibility="visible"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/accatext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/anumber"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:gravity="center"
android:paddingLeft="2dp"
android:singleLine="true"
android:text="09876543210987654321"
android:textColor="@color/numbertext"
android:textSize="16sp"
tools:ignore="RtlSymmetry,RtlHardcoded,HardcodedText" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/footer_band" />
</LinearLayout>
</ScrollView>
With the above code.. Toolbar is also scrolled and hence it get cut too. Is there a way freeze toolbar and then scroll other views.
It would be great if somebody could guide me?
Thanks!
Just do something like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Rest of your content -->
</LinearLayout>
</ScrollView>
</LinearLayout>
Just put the Toolbar above the ScrollView, and then, add then add the layout_below parameter in the ScrollView, so you make sure it appears under the Toolbar.
It definitely works.
<RelativeLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:app = "http://schemas.android.com/apk/res-auto"
xmlns:ads = "http://schemas.android.com/apk/res-auto"
xmlns:tools = "http://schemas.android.com/tools"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
app:layout_behavior = "@string/appbar_scrolling_view_behavior"
tools:showIn = "@layout/category_layout">
<include
android:id="@+id/toolbar"
layout="@layout/tool_bar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With