简体   繁体   中英

Change the sliding bar color on alert dialog?

I'd like to change the sliding bar color on an alert dialog when you have a listview. Actually, I do understand how to change the background color by doing this :

final AlertDialog alertDialog = new AlertDialog.Builder(new ContextThemeWrapper(fragmentActivity, R.style.AlertDialogCustom)).create();

And then :

<style name="AlertDialogCustom" parent="@android:style/Theme.Dialog">
    <item name="android:textColor">#000000</item>
    <item name="android:background">#d3d3d3</item>
</style>

But I don't find anything to change color of the sliding bar on the right.

You can set Listview property as:

android:scrollbarSize="10dp"
android:scrollbarThumbVertical="@drawable/custom_scroll_style"

Here custom_scroll_style is a xml file under the drawable folder. Lets create the custom_scroll_style.xml.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="45"
android:endColor="#FF3401"
android:centerColor="#ff5c33"
android:startColor="#FF3401" />
<corners android:radius="8dp" />
<size android:width="4dp"/>
<padding
android:left="0.5dp"
android:right="0.5dp" />
</shape>

Hope it will help you out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM