How can I change the color of the line in a Dialog
below:
-
why don't you create a custom dialog override the default dialog – Trikaldarshiii Mar 21 '14 at 03:00
-
@PrimeMinisterofIndia I did, can you please explain a bit more how to do that? – 0xSina Mar 21 '14 at 03:04
3 Answers
Unfortunately you'll have to inflate your own layout. Here's your answer:
How can I change the color of AlertDialog title and the color of the line under it

- 1
- 1

- 896
- 7
- 19
create a custom AlertDialog and set custom title view using setCustomTitle.
public AlertDialog.Builder setCustomTitle (View customTitleView)
Set the title using the custom view customTitleView. The methods setTitle(int) and setIcon(int) should be sufficient for most titles, but this is provided if the title needs more customization. Using this will replace the title and icon set via the other methods.
from this link.. http://developer.android.com/reference/android/app/AlertDialog.Builder.html#setCustomTitle%28android.view.View%29

- 16,967
- 7
- 61
- 83
If you don't want to create a custom layout, you can access to the divider View
using Resources.getIdentifier
after subclassing AlertDialog
then calling AlertDialog.findViewById
. Here's a quick example:
/**
* {@inheritDoc}
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final CustomDialog cd = new CustomDialog(this);
cd.setTitle("Title");
cd.setMessage("Message");
cd.show();
}
private static final class CustomDialog extends AlertDialog {
private CustomDialog(Context context) {
super(context);
}
/**
* {@inheritDoc}
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Resources res = getContext().getResources();
final int id = res.getIdentifier("titleDivider", "id", "android");
final View titleDivider = findViewById(id);
if (titleDivider != null) {
titleDivider.setBackgroundColor(Color.RED);
}
}
}

- 30,484
- 10
- 122
- 151