-1

I am using an alert dialog for displaying some checkboxes.I need a TRANSPARENT view for the whole alertview and for it contents.I tried many way...but not helps me...can anybody help me...any help will be highly apppreciated....

code for creating alert dialogue in java

Context c = getParent();
                                m_adapter = new Intrested_in_adapter(
                                        Requestclass.this,
                                        R.layout.intrestedin, offferList);

//                              Dialog dialog = new Dialog(this, R.style.NewDialog);
//                              mDialog = new AlertDialog.Builder(c,R.style.NewDialog);
                                mDialog = new AlertDialog.Builder(c);
                                mDialog.setTitle("Intrested In");

                                mDialog.setAdapter(m_adapter,
                                        new DialogInterface.OnClickListener() {
                                            public void onClick(
                                                    DialogInterface dialog,
                                                    int item) {

                                            }
                                        });

                                alertDialog = mDialog.create();
                                Log.e(tag,"before background setting");
//                              alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
//                              alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
                                Log.e(tag,"after background setting");

                                alertDialog.show();

xml for alert dialogue(intrestedin.xml)

<?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:orientation="vertical" 

    >
     <CheckBox
        android:id="@+id/checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000000"

         />
</LinearLayout>
M D
  • 47,665
  • 9
  • 93
  • 114
Miller
  • 744
  • 3
  • 15
  • 39

3 Answers3

0

May be this helps

<?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:orientation="vertical" 
    android:background="@android:color/transparent" //make background transparent here by using this line
>
 <CheckBox
    android:id="@+id/checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000000"

     />

0

You can just set a default android theme so, there is no need to set NoTitleBar in extra params, then try a once it will working.

dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
Dhaiyur
  • 98
  • 9
GovindRathod
  • 867
  • 1
  • 8
  • 22
  • is there any issue related to the builder?I mean mDialog = new AlertDialog.Builder(c); any default colour for this? – Miller Apr 01 '15 at 11:14
  • No there is no issue, but if you want to color for this then you have to create a custom style and after apply it at here. – GovindRathod Apr 01 '15 at 12:57
  • private Builder mDialog; mDialog = new AlertDialog.Builder(c, android.R.style.Theme_Translucent_NoTitleBar); I give the above code as like this ...it wont works .....anything wrong with it.....Still i am getting that white background...not transparent – Miller Apr 01 '15 at 13:02
0
<style name="TransparentDialog">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:background">@android:color/transparent</item>
</style>

use in java

Dialog dialog = new Dialog(this, R.style.TransparentDialog);

Hope this will help you!!..

Vijay
  • 3,152
  • 3
  • 24
  • 33