How can I edit the scroll height in Android "ScrollView"?
-
1what do you mean by that ?!! editing the Height of scrollView or the height of it's bar ? and what are you did try so far ? – Muhammed Refaat Jan 22 '15 at 09:52
-
editing the Height of scrollView or the height of it's bar ? scrollbar – Andro Jan 22 '15 at 10:04
-
I want to add custom image for scroll in scrollView – Andro Jan 22 '15 at 10:12
-
Make your `ScrollView` width to "fill_parent" . – GrIsHu Jan 22 '15 at 11:45
1 Answers
you can't change the height
of the ScrollView-bar as it depends on the contents of the ScrollView(like any scroll bar), which means you will have a short one for many contents and a tall one for less contents, but instead you can change the width of vertical scrollbars and height of horizontal scrollbars using android:scrollbarSize=""
, and there is workaround to achieve that, just control the Height
of the scrollView
and this will control the Height of it's bar, and to achieve that just refer to this answer.
And when talking about adding a custom image for scroll it can be done using:
android:scrollbarThumbVertical=""
which
Defines the vertical scrollbar thumb drawable
or:
android:scrollbarThumbHorizontal=""
which
Defines the horizontal scrollbar thumb drawable.
Update:
To control the width and height of your scroll bar, add your drawable image to a layer_list with a sized shape and save it as a drawable then use it back:
your_shape.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/your_image">
<shape
android:padding="10dp"
android:shape="rectangle" >
<size
android:height="20dp"
android:width="10dp" />
</shape>
</item>
</layer-list>
So, just save it to your drawable folder and add it as a thumb (don't forget to change the width and height I put to something fits according to your needs):
android:scrollbarThumbHorizontal="R.drawable.your_shape.xml"

- 1
- 1

- 8,914
- 14
- 83
- 118
-
So, what do you want to achieve? the before image or the after image? and what is the missing part that you want to achieve – Muhammed Refaat Jan 22 '15 at 11:40
-
-
@MuhammedRefaat your update is not working for me (recyclerview and androidX) – JavierSegoviaCordoba Jan 10 '19 at 12:28
-