I want to modify AlertDialog.Builder's title and body style.
Son I use setCustomTitle and setView to arrive this.
Below is the simplify code:
private AlertDialog dialog;
public void Showdialog() {
LayoutInflater inflaterTitle = getLayoutInflater();
View TitleView = inflaterTitle.inflate(layout, (ViewGroup)findViewById(id));
TextView Title = (TextView)TitleView.findViewById(id);
Title.setText("Title");
LayoutInflater inflaterBody = getLayoutInflater();
View BodyView = inflaterBody.inflate(layout, (ViewGroup)findViewById(id));
TextView Body = (TextView)BodyView.findViewById(id);
Body.setText("Body");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCustomTitle(TitleView);
builder.setView(BodyView);
dialog = builder.create();
dialog.show();
}
The TitleView and BodyView with bule background.
The show dialog as below.
There contain 2 black.
How can I remove it?
Try Dialog with custom layout as following...
res/layout/main.xml:
res/layout/custom.xml:
MainActivity.java:
Instead of that, if you want to have custom layout for dialog then use below code.
styles.xml in Values resouces:
This will help you a lot. You can set any view as per your need.