Android 设计图标化自定义对话框布局

标签 android

下图是我想将其设计为自定义对话框布局,我的问题是:我无法将圆形 ImageView 作为对话框图标放在布局之上

enter image description here

我的布局 xml 文件:

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

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             android:layout_gravity="center">

    <ir.pishguy.signalpresentationproject.Widgets.CircularRevealView
        android:id="@+id/reveal"
        android:layout_width="match_parent"
        android:layout_height="350dp"
        android:layout_gravity="center"/>

    <FrameLayout
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <de.hdodenhof.circleimageview.CircleImageView
            android:layout_width="55dp"
            android:layout_height="55dp"
            android:src="@drawable/ic_messages"
            app:civ_border_color="#ffffff"
            app:civ_border_width="5dp"
            android:layout_marginTop="-35dp"
            android:id="@+id/store_avatar"
            android:layout_gravity="top"/>

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="vertical">


            <ScrollView
                android:id="@+id/scrollView"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                              android:layout_width="match_parent"
                              android:layout_height="match_parent"
                              android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:text="New Text"/>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:text="New Text"/>
                </LinearLayout>
            </ScrollView>
        </LinearLayout>
    </FrameLayout>
</FrameLayout>

我的布局截图:

enter image description here

最佳答案

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:background="@android:color/transparent">

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginTop="55dp"
        android:background="@android:color/holo_blue_dark"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="60dp"
            android:text="@string/app_name"
            android:textColor="@android:color/black"
            android:textSize="22sp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="16dp"
            android:background="@android:color/white"
            android:gravity="center"
            android:text="Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! "
            android:textColor="@android:color/black"
            android:textSize="18sp" />

        <Button
            android:id="@+id/alert_btn_cancel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:background="#FF00F5"
            android:text="Done"
            android:textColor="@android:color/white"
            android:textSize="18sp" />
    </LinearLayout>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:src="@mipmap/ic_launcher" />
</RelativeLayout>

关于Android 设计图标化自定义对话框布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37879036/

相关文章:

java - 如何在 Android 上使用 pocketsphinx 添加音素识别

android - java.lang.NoClassDefFoundError : Failed resolution of: Lorg/jacoco/agent/rt/internal_773e439/Offline; 错误

android - Android 中的 Firebase 通知

java - Android OpenGLES 在 GLThread 中加载纹理然后告诉 UI 线程运行一个方法

android - 组合多个导航的 react 导航

java - 安卓/Java : open a link in Chrome using a specific tab (not the last one)

Android、GET 和应用程序引擎 : Cloud Endpoints vs GWT RPC?

java - Android 非法状态异常 : The specified child already has a parent

java - 使用 AES256 对称分组密码的图像加密/解密

java - 如何永久禁用操作栏/导航栏/状态栏 android 4.2.2