【发布时间】:2011-12-09 14:50:51
【问题描述】:
这可能很容易,但我在任何地方都找不到答案。
我将 setCustomTitle 用于我的警报对话框,以便将我自己的视图用于对话框标题:
View customTitle = getLayoutInflater().inflate(R.layout.dialog_title, null);
new AlertDialog.Builder(AddBusActivity.this).setCustomTitle(customTitle).(some more stuff).show();
还有 dialog_title.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:text="My Title"
android:id="@+id/title"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:gravity="right|center_vertical">
</TextView>
</LinearLayout>
我的问题是让标题TextView 使用默认对话框标题样式。
在我的设备中,警报对话框背景是暗的,因此文本必须是亮的,但在其他设备中可能会有所不同。
我尝试将 android:textAppearance="@android:style/TextAppearance.DialogWindowTitle" 添加到 TextView,但它导致文本为黑色,而不是正确的风格。
我该如何解决这个问题?
【问题讨论】:
标签: android android-layout android-ui android-styles