2012-02-11 35 views
2

AlertDialogでタイトルの下線の色を変更する方法はありますか? 私はすでにカスタムスタイル定義(下記参照)でタイトルカラーを変更しましたが、下線のxml属性は見つかりませんでした。私はAndroidの4AlertDialogタイトルの下線の色

編集を実行している

<style name="CustomTitle" parent="@android:style/TextAppearance.Holo"> 
    <item name="android:textColor">@color/green</item> 
    </style> 

:それは私がAlertDialog

 Builder ad = new AlertDialog.Builder(new ContextThemeWrapper(this, 
      R.style.DialogPrivate)); 
    ad.setTitle("Custom Dialog"); 

    ad.setMessage("blaaaaa"); 
    ad.setPositiveButton("test", null); 
    ad.setNegativeButton("test2", null); 
    ad.show(); 

作成方法ですそして、それは現時点でどのように見えるかScreenshot

+0

http://stackoverflow.com/questions/2394935/can-i-underline-text-inを参照してください。 -an-android-layout – AliSh

+0

タイトルTextViewにどうやってアクセスできますか?私はデフォルトのAlertDialogを使用していますが、拡張していません。 – user1173367

答えて

-1

アンドロイド使用してみてください: textColorLink = "#783302"

+0

残念ながら、この属性では色は変わりません。 @ color/privateColor user1173367

1

この返信は少し遅れていますが、私は「下線」は実際には背景として使用される9パッチ画像ファイルの一部です。色を変更するには、その背景イメージを変更する必要があります。

2

実際には、アンダーラインは背景色がデフォルトのホロブルー(ゼリービーンatleast)に設定されたViewオブジェクトです。

アラートダイアログのレイアウトは、https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/alert_dialog_holo.xml#L58にあります。具体的には、titleDividerビュー:

<View android:id="@+id/titleDivider" 
     android:layout_width="match_parent" 
     android:layout_height="2dip" 
     android:visibility="gone" 
     android:background="@android:color/holo_blue_light" /> 

ザッツ不幸、それは、次のようないくつかの醜い、ハックコードせずにビューの色をカスタマイズする方法はありません意味するので:

void changeUnderlineColor(AlertDialog d, int color) { 
    final ViewGroup v = (ViewGroup) d.getWindow().findViewById(android.R.id.content); 
    v.findViewById(getResources().getIdentifier("titleDivider", "id", "android")).setBackgroundColor(color); 
} 

これは、使用してJellybeanに取り組んでいますが、 holo_lightのテーマですが、それはほとんど間違いです。実際に線の色を変更したい場合は、自分で完全にカスタムのダイアログを作成する必要があるようです。