Reputation: 339
I created an Activity as a dialog using the code below which I put in my manifest. But the problem is it has Title bar, how can I remove it?
android:theme="@android:style/Theme.Dialog"
Upvotes: 10
Views: 15237
Reputation: 564
I try requestWindowFeature(Window.FEATURE_NO_TITLE); but not working for me, if you are like me so do this : first Add the following code in your res/values/styles.xml:
<style name="NoTitleDialog" parent="Theme.AppCompat.Dialog">
<item name="android:windowNoTitle">true</item></style>
Pass the theme to your dialog:
Dialog dialog = new Dialog(this, R.style.NoTitleDialog);
that's it very simple
Upvotes: 0
Reputation: 4021
For those who are using AppCompatActivity, above answers may not work.
Try this
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
immediately before setContentView(R.layout.my_dialog_activity);
Upvotes: 3
Reputation: 1840
It work for me:
In the onCreate() of my custom Dialog Activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_alert_dialogue);
//your code....
}
Manifest:
<activity android:name=".AlertDialogue"
android:theme="@style/AlertDialogNoTitle">
</activity>
Style:
<style name="AlertDialogNoTitle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
Upvotes: 1
Reputation: 1020
Remove Title Bar from Activity extending ActionBarActivity or AppcompatActivity with Dialog Theme
<style name="Theme.MyDialog" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Upvotes: 1
Reputation: 1451
For Me following worked :
<style name="MyActivityDialogTheme" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Upvotes: 8
Reputation: 97
Handler _alerthandler = new Handler();
Runnable _alertrunnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
ProfileActivity.this.runOnUiThread(new Runnable() {
public void run() {
// Create custom dialog object
final Dialog dialog = new Dialog(ProfileActivity.this);
// Include dialog.xml file
dialog.getWindow();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.alertbox);
TextView title = (TextView) dialog
.findViewById(R.id.AlertBox_Title);
title.setText(Appconstant.Toast_Title);
TextView text = (TextView) dialog
.findViewById(R.id.AlertBox_Msg);
text.setText(Appconstant.Toast_Msg);
dialog.show();
Button declineButton = (Button) dialog
.findViewById(R.id.AlertBox_Ok);
// if decline button is clicked, close the custom dialog
declineButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Close dialog
dialog.dismiss();
}
});
}
});
}
};
Upvotes: 0
Reputation: 40416
if Dialog ..............
Dailog dialog = new Dialog(MainActivity.this, R.style.mydialogstyle);
res-->values-->mydialog.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mydialogstyle" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">false</item>
</style>
</resources>
Upvotes: 8
Reputation: 1946
this is work for me
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="mydialogstyle" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
and this
requestWindowFeature(Window.FEATURE_NO_TITLE);
Upvotes: 1
Reputation: 5793
Use This Code
final Dialog dialog = new Dialog(context);
dialog.getWindow();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.yourlayout);
dialog.show();
Upvotes: 12
Reputation: 8695
Use this code when creating a dialog:
requestWindowFeature(Window.FEATURE_NO_TITLE);
Upvotes: 4