Android SeekBar cannot be full width, even if installing add-on 0 in AppCompat 23.1.0

when I upgrade support for Android support from 23.0.1 to 23.1.0, I find that SeekBar is no longer full width.

This is a test XML file:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="@drawable/space_divider" android:orientation="vertical" android:padding="8dp" android:showDividers="middle"> <View android:layout_width="match_parent" android:layout_height="20dp" android:background="@android:color/black"/> <!-- default SeekBar --> <SeekBar android:layout_width="match_parent" android:layout_height="10dp" android:progress="50" android:progressTint="@android:color/holo_red_dark"/> <!-- padding=0 --> <SeekBar android:layout_width="match_parent" android:layout_height="10dp" android:padding="0dp" android:progress="50" android:progressTint="@android:color/holo_red_dark"/> <!-- padding=40 --> <SeekBar android:layout_width="match_parent" android:layout_height="10dp" android:padding="40dp" android:progress="50" android:progressTint="@android:color/holo_red_dark"/> <android.support.v7.widget.AppCompatSeekBar android:layout_width="match_parent" android:layout_height="10dp" android:padding="0dp" android:progress="50"/> </LinearLayout> 

It works well under lib 23.0.1 support, like the following screenshot. SeekBar has a default padding, when I set padding = 0 manual, it can be full width. and AppCompatSeekBar does not exist yet.

enter image description here

but under lib 23.1.0 support, regardless of whether the fill size is set, SeekBar and AppCompatSeekBar do not have any changes, for example, the following screenshot.

enter image description here

So, is this a lib support bug, is any authority responding to this problem and how to solve it?

thanks ~!

update:
This completely confused me, I just have one more test, I create a new project, regardless of whether I use AppCompat 23.0.1 or 23.1.0, SeekBar cannot be full width after setting padding = 0 (compileSdkVersion is 23, buildToolsVersion - 23.0.1 ", targetSdkVersion - 23). Anyway, I want to know how to make the SeekBar full width when set padding = 0 does not work.

build.gradle:

 apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.test.seekbar" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.0.1' } 
+20
source share
4 answers
Finally, I just thought. why not try changing it with java code. It is working! following code example:
 protected void initViews(Context context) { LayoutInflater.from(context).inflate(getLayoutResId(), this); ButterKnife.bind(this); // set style, just once seekBar.setProgress(0); seekBar.setMax(0); seekBar.setPadding(0, 0, 0, 0); // ... } 
+29
source

Set these attributes in XML

 android:paddingStart="0dp" 
+19
source

Try adding the paddingStart and paddingEnd to 0dp in the XML file. If your application is compatible with Rtl, you will need to add them to render seekBar without indentation, otherwise it will be displayed with indentation, even if you use it in Ltr.

+13
source

As Didak mentioned, you can set the indent to 0 in xml.

But make sure you set the indentation after you set progressTint or progressDrawable .

I had a similar problem (where I installed progressDrawable). After I set padding to 0 after setting progressDrawable , padding on seekbar disappeared

+2
source

All Articles