Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android custom dialog shows android title bar

I have made an xml file like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="bottom"
              android:layout_gravity="bottom"
              android:background="#04600F"
              android:padding="10dp">

              <TextView android:id="@+id/txtMessage"
                        android:layout_width="fill_parent" 
                        android:gravity="center"
                        android:layout_height="wrap_content"/>

              <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                              android:orientation="horizontal"
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content">

                            <Button android:id="@+id/btnOne"
                                    android:layout_width="wrap_content" 
                                    android:layout_height="wrap_content"
                                    android:textSize="20dip"
                                    android:textColor="#ffffff"
                                    android:layout_alignParentLeft="true"
                                    android:background="@drawable/black_menu_button"
                                    android:layout_marginLeft="5dip"
                                    android:layout_centerVertical="true"
                                    android:layout_centerHorizontal="true"/> 

                            <Button android:id="@+id/btnTwo"
                                    android:layout_width="wrap_content" 
                                    android:layout_height="wrap_content"
                                    android:textSize="20dip"
                                    android:textColor="#ffffff"
                                    android:layout_alignParentRight="true"
                                    android:background="@drawable/blue_menu_button"
                                    android:layout_marginRight="5dip"
                                    android:layout_centerVertical="true"
                                    android:layout_centerHorizontal="true"/>
              </RelativeLayout>
</LinearLayout>

And I try to access it like this:

    final Dialog dialog = new Dialog(ctx,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    dialog.setContentView(R.layout.myxml);
.....

It looks on the screen exactly how I want it, on the bottom of it. My application has the following set on AndroidManifest:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

The only draw back of what I did is the fact that the Android title bar (the one with battery/signal... ) becomes visible as long as my Dialog is visible. How can I disable it ?

Later edit

Thank you for pointing that to me, the solution was fairly simple indeed

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
like image 209
Alin Avatar asked Oct 09 '10 17:10

Alin


1 Answers

The solution was very simple, try the code below:

final Dialog dialog = new Dialog(ctx,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.myxml);
like image 98
sravan Avatar answered Sep 22 '22 22:09

sravan