2017-04-13 8 views
1

イム、 タブレット上で作品を使用してコードイムはロリポップと 以上が、Androidのキットカットを実行している私の携帯電話上のダイアログの上に白のパッチを残し。ダイアログカスタム幅高さの問題

enter image description here

コードは、setContentViewrequestFeature(Window.FEATURE_NO_TITLE)を追加する必要があります

Dialog dialog = new Dialog(this); 
dialog.setContentView(R.layout.dialog_documentationissue_notification); 
dialog.setCancelable(true); 

DisplayMetrics displaymetrics = new DisplayMetrics(); 
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); 
int width = (int) (displaymetrics.widthPixels * 0.90); 
int height = (int) (displaymetrics.heightPixels * 0.70); 
dialog.getWindow().setLayout(width,height); 
//dialog.getWindow().getAttributes().windowAnimations = R.style.NotificationDialogAnimation; 
dialog.show(); 

レイアウト

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:background="@android:color/transparent" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.15" 
     android:background="#3F51B5" 
     android:orientation="vertical"> 

     <View 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.85" 
     android:background="@color/white" 
     android:orientation="vertical"> 

     <View 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

    </LinearLayout> 

</LinearLayout> 

答えて

0

解決方法1:

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 

setContentViewの前に()。

解決方法2:

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

カスタムスタイルを追加し

マニフェストファイルに

<activity android:name=".youractivity" android:theme="@style/myDialog"></activity> 
をこの行を追加し、

をありがとう
2

スニペット。

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); //Optional 
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 
dialog.setContentView(R.layout.dialog_documentationissue_notification); 
0

この白い部分がタイトルのため、この方法でタイトルを非表示にすることができます。

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before  
dialog.setContentView(R.layout.logindialog); 
関連する問題