【发布时间】:2014-03-11 15:00:42
【问题描述】:
我完全按照http://www.lukehorvat.com/blog/android-seekbardialogpreference
中解释的方式实现了 DialogPreference此外,我还能够更改 DialogPreference 的文本和分隔线颜色,但无法更改按钮按下时的突出显示颜色。有人知道怎么做吗?
更新:
我为 DialogPreference 使用以下布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text_dialog_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dip"
android:paddingLeft="12dip"
android:paddingRight="12dip"/>
<TextView
android:id="@+id/text_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dip"
android:gravity="center_horizontal"/>
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginTop="6dip"/>
</LinearLayout>
关于这个 DialogPreference 或我目前更改的布局的唯一样式属性是以编程方式更改的:
int alertTitleId = this.getContext().getResources().getIdentifier("alertTitle", "id", "android");
TextView alertTitle = (TextView) getDialog().getWindow().getDecorView().findViewById(alertTitleId);
alertTitle.setTextColor(color); // change title text color
int titleDividerId = this.getContext().getResources().getIdentifier("titleDivider", "id", "android");
View titleDivider = getDialog().getWindow().getDecorView().findViewById(titleDividerId);
titleDivider.setBackgroundColor(color); // change divider color
【问题讨论】:
-
您的布局是自定义或默认的
-
看看最新的更新:)