[英]Alert dialog box Shifting left and right
好吧,我已經在警報對話框中實現了圓角目標,但是它占據了所有左側和右側。 我的問題就像我想在對話框的左右之間留一些空間這是我的代碼:“自定義”對話框
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/custom_dialog"
>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="SELECT PHOTO"
android:textSize="15dp"
android:paddingBottom="12dp"
android:paddingTop="12dp"
android:layout_marginLeft="20dp"></TextView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/hint_color"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="15dp"
android:id="@+id/Select_photo_from_Camera">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/camera_24dp"
android:layout_marginLeft="22dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Camera"
android:layout_marginLeft="10dp"
></TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="600dp"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="@color/hint_color"></View>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="15dp"
android:paddingBottom="5dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_photo_library_black_24dp"
android:layout_marginLeft="22dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gallery"
android:layout_marginLeft="10dp"
/>
</LinearLayout>
</LinearLayout>
:Custom_dialog.xml的代碼
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@color/white"></solid>
<corners
android:radius="5dp"
></corners>
<padding
android:top="6dp"
android:bottom="6dp"></padding>
</shape>
這是我的成就的輸出:
創建一個插圖並將其設置為背景,這可能會有所幫助
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/your_background_image"
android:insetRight="25dip"
android:insetLeft="25dip" />
采用
android:background="@drawable/inset_background"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.