2016-09-19 114 views
2

我想在有列表視圖時更改警告對話框上的滑動條顏色。其實,我明白瞭如何通過這樣來改變背景顏色:更改警報對話框上的滑動條顏色?

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

然後:

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

但我沒有找到任何改變右側的滑動條的顏色。

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

這裏custom_scroll_style是繪製文件夾下的xml文件:

+0

你指的是什麼「滑動按鈕」? –

+0

你想按鈕的顏色對話框按鈕? –

+0

如果你指的是'AlertDialog'按鈕,請嘗試'android:colorAccent' – hrskrs

回答

0

,你可以設置列表視圖屬性。讓我們創建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> 

希望它能幫助你。

+0

哦,對不起!並不是一個真正的按鈕。當你有一個列表視圖時,我正在討論右邊的滾動條。我想改變這個顏色。讓我編輯我的問題。 –

+0

好極了!我會試試這個,然後給你一個反饋。 –

+0

你的解決方案真的很棒。但是,我無法直接使用alertDialog直接使用setAdapter。我不得不使用setView和alertdialog,並使用它自己的適配器來擴充listview。 –