2010-10-09 44 views
6

Tôi đã thực hiện một tập tin xml như thế này:thoại tùy chỉnh Android hiển thị tiêu đề android thanh

<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> 

Và tôi cố gắng truy cập vào nó như thế này:

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

Có vẻ trên màn hình một cách chính xác làm thế nào tôi muốn nó, ở dưới cùng của nó. Ứng dụng của tôi đã thiết lập sau đây trên AndroidManifest:

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

Các chỉ vẽ lại những gì tôi đã làm là một thực tế rằng các thanh tiêu đề Android (một với pin/tín hiệu ...) trở nên rõ ràng càng lâu càng Dialog của tôi có thể nhìn thấy. Làm thế nào tôi có thể vô hiệu hóa nó?

Sau đó chỉnh sửa

Cảm ơn bạn đã chỉ mà đối với tôi, giải pháp là khá đơn giản thực sự

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
+3

Liệu này giải pháp giúp đỡ? http://stackoverflow.com/questions/2644134/android-how-to-create-a-dialog-without-a-title –

Trả lời

17

Giải pháp là rất đơn giản, hãy thử đoạn code dưới đây:

final Dialog dialog = new Dialog(ctx,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); 
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
dialog.setContentView(R.layout.myxml); 
Các vấn đề liên quan