Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

android - Set Transparent Window in AlertDialog box

I want to set the Transparent window for the Default alertDialogbox. . . How can i able to do it ?? My Alertbox is as like this. Please refer it. .

Thanks in Advance. .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The link is for activity How do I create a transparent Activity on Android?

but still you can apply the same theme for dialog box too.

Edit

Create a class for the dialog as below

CustDialog.java :

public class CustomDialog extends Dialog implements android.view.View.OnClickListener {

    Button button_home,button_cancel,button_resume;
    public GamePauseMenu(Context context) {
        super(context,R.style.Theme_Transparent);


    }
    public void show(int bg) {
        // TODO Auto-generated method stub
        super.show();
        setContentView(R.layout.custdialog);
        button_resume = (Button)findViewById(R.id.imageButton1);
        button_resume.setOnClickListener(this);
    }
    public void onClick(View v) {
        cancel();

    }


}

custdialog.xml in Layout :

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/linearLayout1"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:gravity="center|center_vertical|center_horizontal"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <Button android:id="@+id/imageButton1" android:background="@drawable/menu_home"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:drawingCacheQuality="auto" android:duplicateParentState="true"></Button>
    <Button android:background="@drawable/menu_next" android:id="@+id/imageButton2"
        android:layout_height="wrap_content" android:layout_width="fill_parent"></Button>
    <Button android:id="@+id/imageButton3" android:background="@drawable/menu_reset"
        android:layout_height="wrap_content" android:layout_width="fill_parent"></Button>

</LinearLayout>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...