我使用下面的代码创建了一个Activity作为对话框,我将其放入清单中。但问题是它有标题栏,我该如何删除它?
android:theme="@android:style/Theme.Dialog"
答案 0 :(得分:12)
使用此代码
final Dialog dialog = new Dialog(context);
dialog.getWindow();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.yourlayout);
dialog.show();
答案 1 :(得分:8)
如果对话..............
Dailog dialog = new Dialog(MainActivity.this, R.style.mydialogstyle);
<强> RES - &GT;值 - &GT; 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>
答案 2 :(得分:7)
对于我的工作:
<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>
答案 3 :(得分:3)
创建对话框时使用此代码:
requestWindowFeature(Window.FEATURE_NO_TITLE);
答案 4 :(得分:2)
对于使用AppCompatActivity的用户,以上答案可能无效。
尝试一下
=SUM(SPLIT(A1,":"))
答案 5 :(得分:1)
这对我有用
<?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>
和这个
requestWindowFeature(Window.FEATURE_NO_TITLE);
答案 6 :(得分:1)
从活动中移除标题栏,使用对话框主题 ActionBarActivity 或 AppcompatActivity
<style name="Theme.MyDialog" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
答案 7 :(得分:1)
它对我有用:
在我的自定义对话框活动的onCreate()中:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_alert_dialogue);
//your code....
}
清单:
<activity android:name=".AlertDialogue"
android:theme="@style/AlertDialogNoTitle">
</activity>
样式:
<style name="AlertDialogNoTitle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
答案 8 :(得分:0)
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();
}
});
}
});
}
};