0
I have the following dialog box:
The green part was mounted with a LinearLayout
, but the attribute android:background="#77FF77"
did not change the titlebar color.
Java da Dialog:
public void ver_log(View v){
DialogLog();
}
private void DialogLog(){
final Dialog dialogLog = new Dialog(this);
dialogLog.setContentView(R.layout.dialog_log);
dialogLog.setTitle("CÁLCULOS");
final Button btnFechar = (Button) dialogLog.findViewById(R.id.btn_fechar);
final Button btnCopiar = (Button) dialogLog.findViewById(R.id.btn_copiar);
btnFechar.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dialogLog.dismiss();
}
});
btnCopiar.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Ação de copiar
}
});
dialogLog.show();
}
XML of the Dialog:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
style="@style/Dialogs" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/relatorio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
style="@style/BotoesDialogs"
android:id="@+id/btn_fechar"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/fechar" />
<Button
style="@style/BotoesDialogs"
android:id="@+id/btn_copiar"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/copiar" />
</LinearLayout>
</LinearLayout>
How can I change that part? It would also be possible to change the color of the title "CALCULUS" and this blue bar below?
You have two ways, or write the style’s of
Dialog
in your theme. Or remove the title (usingrequestWindowFeature(Window.FEATURE_NO_TITLE)
in theonCreate
, before anything) and creates a custom title for theDialog
, within the layout of your contentDialog
.– Wakim
While this does not answer your question, it may help you: https://github.com/inmite/android-styled-dialogs
– Cícero Moura
It worked, @Wakim. I used
requestWindowFeature(Window.FEATURE_NO_TITLE)
placing just above the layout definition of theDialog
. Thank you!– EdeiltonSO