2012-04-27 21 views
2

ダイアログレイアウトのxml:アンドロイド:変更したカスタムAlertDialog背景

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/root_view" 
    android:padding="3dp" 
    android:background="@android:color/white" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    //...content... 

</TableLayout> 
マップオーバーレイで

ダイアログ実装画鋲でタップ:

AlertDialog.Builder builder; 

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE); 
View layout = inflater.inflate(R.layout.map_kap_dialog, 
        (ViewGroup) mapView.findViewById(R.id.root_view)); 

//prepare info to show... 
//info prepared 

//other preparations stuff 
builder = new AlertDialog.Builder(context); 
builder.setView(layout); 
dialog = builder.create(); 
dialog.setInverseBackgroundForced(true); 
dialog.setCanceledOnTouchOutside(true); 
//show it 
dialog.show(); 

をし、私が見たときに、テストそれ:

enter image description here

だから、私はダイアログボックスの周囲に明るい灰色の背景白い空白)が白に変わるので、醜く見えません。誰でも助けてくれますか?

答えて

1

あなたのビューをビルダーに設定すると、このグレーの線が上から下に作成されます。その代わりに、dialog.likeViewに設定することができます。dialog.setView(layout、0,0,0,0);レイアウト全体をダイアログ。

9

私は同じ問題を抱えていた、私はこのようなカスタムダイアログを使用して、それを修正するために管理:

public class CustomDialog extends Dialog { 
    public CustomDialog(Context context, View view) { 
     super(context); 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(view); 
     getWindow().getDecorView().setBackgroundResource(android.R.color.transparent); 
    } 
} 
0

別のオプションは、あなたのレイアウトからandroid:background="@android:color/white"を削除することです。その後、アラートダイアログのデフォルトの明るい灰色がかった背景が均一に表示されます。 (あなたは暗いテーマに逆行を強いられているので)少なくともそれは素敵に見え、面倒な価値があります。ちょうど私の2セント。

関連する問題