片段对话框中的圆角



我知道人们问过比林多次的问题,但没有人发现我对我没有帮助。我有这样的形状

<solid 
     android:color="#FFFFFF"/>
    <stroke
        android:width="2dp"
        android:color="#FFFFFF"/>
    <corners android:radius="30dp" />
</shape>

将其添加到我的主RelativeLayout,我的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <Button
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:background="@drawable/ic_clear_black_18dp"
        />
    <ImageView
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_centerHorizontal="true"
        android:id="@+id/dialog_icon"
        android:src="@drawable/emilypic"
        android:background="@drawable/cicon"
        />
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:id="@+id/LLTitleandNick"
android:layout_below="@id/dialog_icon"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="10dp"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/dialog_title"
        android:textSize="22sp"
        android:textColor="@color/title_color"
        android:text="Lily Martinson"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/dialog_nickname"
        android:textSize="18sp"
        android:text="lilmartini"
        android:layout_marginLeft="35dp"
    />
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_below="@id/LLTitleandNick"
android:layout_marginTop="30dp"
        android:id="@+id/LLFollowers"
        >
        <ImageView
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:id="@+id/image_like"
            android:layout_marginLeft="30dp"
            android:src="@drawable/ic_favorite_border_black_18dp"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/Followers"
            android:text="Followers"
            />
<ImageView
    android:layout_width="20dp"
    android:layout_height="20dp"
    android:id="@+id/image_follow"
    android:layout_marginLeft="80dp"
    android:src="@drawable/ic_directions_walk_black_18dp"
    />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Following"
            />
        </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:id="@+id/LLwithButtons"
        android:layout_below="@+id/LLFollowers"
        android:layout_marginTop="70dp"
        >
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/ic_question_answer_black_36dp"
            />
        <Button
            android:layout_width="60dp"
            android:layout_height="50dp"
            android:background="@drawable/cicon"
            android:layout_marginLeft="35dp"
            />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
android:background="@drawable/ic_person_add_black_36dp"
            android:layout_marginLeft="40dp"
            />

    </LinearLayout>
</RelativeLayout>

但问题是我需要dialog一些尺寸,我的布局构建了这个dialog但是当我添加shape时,形状适用于所有屏幕,所有元素都会改变它们的位置,对我没有任何好处。我试图更改RelativeLayout(我的主要布局)大小,但shape仍然显示所有screen。我该如何更改此设置?我试图添加主题,例如(Transculent,对不起,可能错误)和其他一些主题,但没有什么对我没有帮助。

/** 转到可绘制文件夹只需制作rounded_corner.xml并粘贴以下代码,仔细检查此 xml 是否在您的可绘制文件夹中创建**/

<?xml version="1.0" encoding="UTF-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke
        android:width="1dp"
        android:color="#4D4D4D"/>
    <corners
        android:radius="7dp" />
    <padding
        android:left="1dp"
        android:right="1dp"
        android:top="1dp"
        android:bottom="1dp"/>
    <solid android:color="#FFF"/>
</shape>

/** 现在转到您的布局.xml复制并粘贴此代码 **/

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@drawable/rounded_corner">
<Button
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/ic_clear_black_18dp"
    />
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:id="@+id/dialog_icon"
android:src="@drawable/emilypic"
android:background="@drawable/cicon"
    />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/LLTitleandNick"
android:layout_below="@id/dialog_icon"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
    >
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/dialog_title"
    android:textSize="22sp"
    android:textColor="@color/title_color"
    android:text="Lily Martinson"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/dialog_nickname"
    android:textSize="18sp"
    android:text="lilmartini"
    android:layout_marginLeft="35dp"
    />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/LLTitleandNick"
android:layout_marginTop="30dp"
android:id="@+id/LLFollowers"
    >
<ImageView
    android:layout_width="20dp"
    android:layout_height="20dp"
    android:id="@+id/image_like"
    android:layout_marginLeft="30dp"
    android:src="@drawable/ic_favorite_border_black_18dp"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/Followers"
    android:text="Followers"
    />
<ImageView
    android:layout_width="20dp"
    android:layout_height="20dp"
    android:id="@+id/image_follow"
    android:layout_marginLeft="80dp"
    android:src="@drawable/ic_directions_walk_black_18dp"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Following"
    />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/LLwithButtons"
android:layout_below="@+id/LLFollowers"
android:layout_marginTop="70dp"
    >
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/ic_question_answer_black_36dp"
    />
<Button
    android:layout_width="60dp"
    android:layout_height="50dp"
    android:background="@drawable/cicon"
    android:layout_marginLeft="35dp"
    />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/ic_person_add_black_36dp"
    android:layout_marginLeft="40dp"
    />
</LinearLayout> </RelativeLayout>

最新更新