这可能很容易,但我无法在任何地方找到答案。
我将 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,但它导致文本为黑色,这不是正确的样式。
我该如何解决这个问题?