Creating cutom dialog box on any apps screen

余生长醉 提交于 2019-12-25 05:52:25

问题


I just want to let it appear that dialog box over any apps screen. I can create dialog box like this.Means Dialog box of application 1 over application 2,3,4... screens.

Please Help to create dialog box activity as in the image?? Here http://i.stack.imgur.com/6Gs8G.png

let me explain, in chrome first i have clicked the file to download, then using intents "Android download manager" used its editor activity to capture the URI.. and created dialog box like this.

but i want to do that, in this image the dialog box of android download manager is over chrome. so how can I create such dialog box that appears on any app/screen when its invoked by intent. when i try to do dialog box without "setContentview" my program crashes.


回答1:


you can use this layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
/>


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="bottom" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Link:"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="right" >

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/browser" />

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/settings" />

            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/editText1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10" >

                <requestFocus />
            </EditText>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="bottom" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Name:"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="right" >

                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/unnamed" />

            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/EditText01"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10" />
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

and in java code as usually define textview and imageview and ... etc.

Button image1 = (Button) dialog.findViewById(R.id.imageView1);

.
.
.

dialog.show();


来源:https://stackoverflow.com/questions/22741796/creating-cutom-dialog-box-on-any-apps-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!