Android Dialog: Removing Title Bar

Android Dialog: Removing title bar

use,

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before     
dialog.setContentView(R.layout.logindialog);

How to remove Alert dialog Title bar

If you don't want title bar in alert dialog then just remove below line from code.

dialogbuilder.setTitle("Login");

If still not working then add below line.

dialogbuilder.requestWindowFeature(Window.FEATURE_NO_TITLE);

How to remove title from custom dialog?

Create a new style, add:

<style name="NoTitleDialog" parent="@android:Theme.Dialog">
<item name="android:windowNoTitle">true</item> </style>

And finally :

Dialog d = new Dialog(this, R.style.nameOfStyle);

Edit:
This answer

Android: How to create a Dialog without a title?

You can hide the title of a dialog using:

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);


Previous version of this answer, which is overcomplicated:

You need to use an AlertDialog. There's a good explanation on the Android Developer's site about custom dialogs.

In very short summary, you do this with code like copied below from the official website. That takes a custom layot file, inflates it, gives it some basic text and icon, then creates it. You'd show it then with alertDialog.show().

AlertDialog.Builder builder;
AlertDialog alertDialog;

Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.layout_root));

TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.android);

builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();

In response to comment:

I assume that TextView with the id nr is in the View you are inflating with View view = inflater..... If so, then you need to change just one bit: instead of dialog.findView... make it view.findView.... Then once you've done that, remember to use dialog.show(), or even builder.show() without bothering to do builder.create().

How to remove title bar from the android activity?

Try this:

this.getSupportActionBar().hide();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

try
{
this.getSupportActionBar().hide();
}
catch (NullPointerException e){}

setContentView(R.layout.activity_main);
}

How to remove the title in Dialog?

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>

Removing title of a DialogFragment

Create your dialog normally, and add a line like this before showing:

myDialog.getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

Edit:
added the .getDialog() call

Edit 2: Tested with the link of your example

I have tested this code now and it works:

public class HelpDialog extends DialogFragment {

public HelpDialog() {
// Empty constructor required for DialogFragment
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//Inflate the XML view for the help dialog fragment
View view = inflater.inflate(R.my_layout, container);

HelpDialog.this.getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

return view;
}

}

and i called the Dialog like that :

HelpDialog dialog = new HelpDialog();
dialog.show(getFragmentManager(),"test");

how to remove title from DialogFragment?

you must override onCreateDialog method in your dialogfragment class.

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
RelativeLayout root = new RelativeLayout(getActivity());
root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(root);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

return dialog;
}


Related Topics



Leave a reply



Submit