2012-02-11 3 views
2

AlertDialog에서 제목 밑줄의 색상을 변경하는 방법이 있습니까? 사용자 정의 스타일 정의 (아래 참조)를 통해 제목 색상을 이미 변경했지만 밑줄에 대한 xml 속성을 찾지 못했습니다. 나는 안드로이드 4.AlertDialog 제목 밑줄 색상

편집을 실행하는거야

<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

이 응답은 약간 늦지 만, hat "밑줄"은 실제로 배경으로 사용되는 9 패치 이미지 파일의 일부입니다. 색상을 변경하려면 해당 배경 이미지를 변경해야합니다.

2

밑줄은 실제로 배경색이 기본 홀로 파란색 (젤리 비어 atleast)로 설정된 View 객체입니다.

경고 대화 상자의 레이아웃은 https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/alert_dialog_holo.xml#L58에서 확인할 수 있습니다. 특히, titleDivider보기 :이 사용 젤리 빈에서 작동

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); 
} 

: 그것은 못생긴, 해키 코드와 같은없이 뷰의 색상을 사용자 정의 할 수있는 방법이 없습니다 의미하기 때문에,

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

은 그게 전부가 불행한 holo_light 테마이지만, 거의 확실하게 나쁜 생각입니다. 실제로 선의 색상을 변경하려는 경우 완전히 사용자 정의 대화 상자를 직접 작성해야하는 것처럼 보입니다.