yun.cloud yun.cloud - 3 months ago 60
Android Question

Seekbar Progress Drawable Resizing different in API 22 vs API 23

I'm using this library for

VerticalSeekBars
in my Android application. In my app, I'm laying multiple vertical seekbars horizontally (like about 10-15?) using
LinearLayout
and
layout_weight
properites. In addition, I'm using a thumb that is supposed to be bigger than the progress (essentially laying on top of the progress) and a custom drawable for the progress as such:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"
android:height="10dp"
android:gravity="center_vertical">
<shape android:shape="rectangle">
<corners android:radius="500dp"/>
<solid android:color="#000000"/>
</shape>
</item>
</layer-list>


On API 23 (which I believe is Marshmallow?), everything lines up correctly and resizing properly across different screen sizes. Awesome. However, on API 22 and below, the progress drawable doesn't adjust itself; instead, it increases it size to have the seekbar thumb fit inside the progress. I've tried to resize the drawable in my code but that still doesn't do anything either. I have drawn it out to show what I mean:

Picture example - excuse my poor drawing skills :(

How do I get API 22/below to match the same behavior API 23 is achieving with the seekbar?

Here's an example of my
VerticalSeekBar
setup:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">

<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.5">

<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
android:layout_width="0dp"
android:layout_height="0dp"
android:max="100"
android:progress="50"
app:seekBarRotation="CW270"
android:progressDrawable="@drawable/custom_track"
android:splitTrack="false"/>

</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>

<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.5">

<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
android:layout_width="0dp"
android:layout_height="0dp"
android:max="100"
android:progress="50"
app:seekBarRotation="CW270"
android:progressDrawable="@drawable/custom_track"
android:splitTrack="false"/>

</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>

</LinearLayout>


Thanks!

Answer

Set minHeight like this:

<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
        ...
        android:maxHeight="2dp"
        .../>
Comments