4

これは簡単かもしれませんが、どこにも答えが見つかりません。

ダイアログタイトルに独自のビューを使用するために、アラートダイアログに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に追加しようとしましたが、テキストが黒くなり、適切なスタイルではありませんでした。

どうすればこれを解決できますか?

4

2 に答える 2