Reputation: 14648
I am trying to create a custom dialog without the title bar and I following SO suggestion by doing the following
propDiag = new Dialog(this);
propDiag.requestWindowFeature(Window.FEATURE_NO_TITLE);
propDiag.setContentView(R.layout.property_daig);
Here is a part of my xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/background"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation= "horizontal">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="fill_parent" android:orientation= "vertical" android:layout_weight="1" >
//COUPLE OF buttons
</LinearLayout>
<View android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.5" ></View>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="fill_parent" android:orientation= "vertical" android:layout_weight="1" >
//COUPLE OF buttons
</LinearLayout>
</LinearLayout>
The problem that it is messing up my layout and everything gets pushed to max right and left
When I do it without the requestWindowFeature, then everything is great except for the title appearing!.
Can anyone explain and recommend a solution? Thanks
Upvotes: 2
Views: 1134
Reputation: 23596
See below code:
I don't have your background image, but just have put the icon image and execute the below code.
Also have attached the screen shot of the output.
Code:
Button test = (Button) findViewById(R.id.button1);
test.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Dialog dialog = new Dialog(MainActivity.this);
dialog.getWindow();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.property_daig);
dialog.show();
}
});
Output:
Hope it will help you.
Enjoy Coding. :)
Upvotes: 3
Reputation: 2755
Try this
final Dialog dialog = new Dialog(context);
dialog.getWindow();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.custom_dialog);
TextView customText = (TextView)dialog.findViewById(R.id.customDialogTitletext);
customText.setText(text);
customText.setTypeface(tf);
Button btnOk = (Button) dialog.findViewById(R.id.buttonOk);
btnOk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
dialog.dismiss();
}
});
dialog.show();
}
Let me know your problem is resolved or not.
Upvotes: 0