2016-12-05 3 views
0

アンドロイド - レイアウトファイルから、私はカスタムダイアログを作ってるんだ

Javaコード奇妙なレイアウトを示すカスタムダイアログ:

Dialog dialog = new Dialog(CategoryActivity.this); 
dialog.setContentView(R.layout.content_privacy_dialog); 
TextView dialog_title = (TextView) dialog.findViewById(R.id.dialog_title); 
dialog_title.setText(getString(R.string.nav_privacy)); 
dialog.show(); 

レイアウトファイル:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:background="@color/dialogBg" 
    android:layout_height="match_parent"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:padding="24dp" 
     android:layout_height="wrap_content" 
     android:id="@+id/dialog_title" 
     android:text="About" 
     android:textSize="20sp" 
     android:textColor="@android:color/white" 
     /> 
</LinearLayout> 

を私はこれを取得しています結果:

enter image description here

トップとブルーバーの空白を非表示にするにはどうすればよいですか?

何か助けていただければ幸いです。

答えて

1

は、代わりに私はあなたがマテリアルダイアログを使用することをお勧めします簡単なダイアログを使用してのこの

Dialog dialog = new Dialog(CategoryActivity.this); 
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
dialog.setContentView(R.layout.content_privacy_dialog); 
TextView dialog_title = (TextView) dialog.findViewById(R.id.dialog_title); 
dialog_title.setText(getString(R.string.nav_privacy)); 
dialog.show(); 
+0

お返事ありがとうございました。それは今働いている。 – Asym

関連する問題