Je ne veux pas afficher l'arrière-plan transparent lorsqu'un dialog
s'ouvre. Pouvez-vous s'il vous plaît suggérer un moyen efficace de le faire?Ne pas afficher l'écran transparent sur fond de boîte de dialogue personnalisée dans Android
Répondre
S'il vous plaît vérifier ma mise en œuvre:
créer un dialogue personnalisé avec ma propre mise en page et ajouté le code suivant lors de créer la boîte de dialogue.
dialog = new Dialog(mActivity, R.style.DialogTransparentTheme);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Mon thème sous style:
<style name="DialogTransparentTheme" parent="android:Theme">
<item name="android:textAllCaps">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:colorControlNormal">@color/app_txt_color</item>
<item name="android:colorControlActivated">@color/app_txt_gray_color</item>
<item name="android:colorControlHighlight">@color/app_txt_gray_color</item>
</style>
Merci beaucoup, c'est exactement ce que je cherchais. –
@Usman Ceci est ma mise en œuvre de dialogue personnalisée, et son travail bien pour moi:
View view = mActivity.getLayoutInflater().inflate(R.layout.common_alert_dialog_layout, null);
TextView titleTextView = (TextView) view.findViewById(R.id.common_alert_dialog_title);
TextView messageTextView = (TextView) view.findViewById(R.id.common_alert_dialog_message);
Button okButton = (Button) view.findViewById(R.id.btn_alert_dialog_ok_button);
titleTextView.setText(getString(R.string.dialog_app_name_header));
messageTextView.setText(getString(R.string.walk_no_network));
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
// Do your action::
}
});
dialog.setContentView(view);
dialog.setCanceledOnTouchOutside(true);
dialog.setCancelable(true);
dialog.show();
dialog.getWindow().setLayout((int) getResources().getDimension(R.dimen.common_dialog_width),
(int) getResources().getDimension(R.dimen.common_diaog_height));
return dialog;
Append le code ci-dessus pour cette boîte de dialogue.
Thnaks, mais quand j'utilise le thème comme ceci "dialog = new Dialog (mActivity, R.style.DialogTransparentTheme);" alors il n'annule pas sur le côté cliquez sur –
Reportez-vous au lien http://stackoverflow.com/questions/8384067/how-to-dismiss-the-dialog-with-click-on-outside-of-the-dialog – Nithinjith
Prenez un butin à ce poste: http://stackoverflow.com/questions/15007272/how-to-change-the-background-color-around-a-dialogfragment – Rob
Fondamentalement, je veux faire cela "android: backgroundDimEnabled = false "par programme –