Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 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 Reply

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...