2016-03-31 22 views
1

İçimde ListView bulunan AlertDialog adresinde özel bir düzen var. Şimdi AlertDialog'un siyah arka planını kaldırmak istiyorum. Alert ÇıkarmaDialog arka planı

  AlertDialog.Builder builder = new AlertDialog.Builder(this); 
      LayoutInflater inflater = this.getLayoutInflater(); 
      View dialogView = inflater.inflate(R.layout.rate_card_layout, null); 
      Button close = (Button) dialogView.findViewById(R.id.btnClose); 
      close.setOnClickListener(new OnClickListener() { 

       @Override 
       public void onClick(View arg0) { 

        dialog.dismiss(); 
       } 
      }); 


      ListView lv = (ListView)dialogView.findViewById(R.id.listView1); 
      RateListAdapter rLAdapter = new RateListAdapter(SActivity.this, 
        listItemsArray); 
      lv.setAdapter(rLAdapter); 

      builder.setView(dialogView); 
      final Dialog dialog = builder.create(); 

      dialog.show(); 

her zamanki gibi

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 

ekleyerek çalıştı. Ama bu işe yaramıyor.

enter image description here

Herhangi bir yardım

büyük takdir edilecektir.

+0

set arka plan – Pavya

+0

alfa özelliğini (değil emin olsa) – Nilabja

+0

atıfta siyah arka plan kullanmayı deneyin? İstediğiniz şeyin görüntüsünü gönderir misiniz? – dsharew

cevap

1

private void updateLayoutParams() { 
    Window window = getDialog().getWindow(); 
    WindowManager.LayoutParams params = window.getAttributes(); 
    params.dimAmount = 0.2f; 

    int margin = getResources().getInteger(R.integer.common_margin); 
    DisplayMetrics metrics = new DisplayMetrics(); 
    ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics); 
    params.width = metrics.widthPixels-margin; 

    window.setAttributes(params); 
    window.setBackgroundDrawableResource(android.R.color.transparent); 
    getDialog().setCanceledOnTouchOutside(false); 

} 
@Override 
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig); 
    Log.d(TAG, "onConfigurationChanged"); 

    updateLayoutParams(); 
} 
0

temasını özelleştirmek için bu kullanmayı deneyin deneyin. Ayrıca stilleri ıin AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom));

AlertDialogCustom beyan Ve ardından istediğiniz gibi stil:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="AlertDialogCustom" parent="@android:style/Theme.Dialog"> 
     <item name="android:textColor">#00FF00</item> 
     <item name="android:typeface">monospace</item> 
     <item name="android:textSize">10sp</item> 
     ............. //background etc 
    </style> 
</resources> 
0

Bu

style.xml özel iletişim stil ekleyin deneyin Faaliyet

yılında

<style name="DialogTheme" parent="@android:style/Theme.Dialog"> 
      <item name="android:windowBackground">@android:color/transparent</item>   
    </style> 

Dialog dialog = new Dialog(this, R.style.DialogTheme); 
senin rate_card_layout içinde

VEYA

AlertDialog.Builder builder=new AlertDialog.Builder(this,R.style.DialogTheme); 
İlgili konular