对话框外的按钮的一部分
Part of a Button outside of a Dialog
我正在努力实现这样的目标:
有没有人知道如何使按钮部分位于对话框之外并始终位于文本下方?
这是我的对话框布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="180"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="24dp"
android:background="@drawable/actionbar_selector"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:id="@+id/imageView4"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:src="@drawable/ic_error_outline" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:text="@string/drive_carefully_title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/blue_light" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="32dp"
android:text="@string/drive_carefully_message"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/blue_light" />
<TextView
android:id="@+id/ok_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="16dp"
android:layout_marginTop="32dp"
android:layout_weight="0.18"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:autoText="false"
android:background="@drawable/ok_button"
android:textColor="@color/blue_medium"
android:text="@string/ok"
android:textSize="24dp"
android:clickable="true"
android:layout_marginLeft="64dp"
android:gravity="center"
android:textStyle="bold">
</TextView>
</LinearLayout>
</RelativeLayout>
这是目前的情况:
You can make it like below if you have Drawable
of that. Just pass that Drawable
reference in below ImageView
.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="25dp"
android:background="#111111">
<!--Your rest of xml code-->
</LinearLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="50dp"
android:src="@drawable/logo" />
</RelativeLayout>
Set Height
and Width
of Image
as per your requirement.
我正在努力实现这样的目标:
有没有人知道如何使按钮部分位于对话框之外并始终位于文本下方?
这是我的对话框布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="180"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="24dp"
android:background="@drawable/actionbar_selector"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:id="@+id/imageView4"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:src="@drawable/ic_error_outline" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:text="@string/drive_carefully_title"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/blue_light" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="32dp"
android:text="@string/drive_carefully_message"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/blue_light" />
<TextView
android:id="@+id/ok_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="16dp"
android:layout_marginTop="32dp"
android:layout_weight="0.18"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:autoText="false"
android:background="@drawable/ok_button"
android:textColor="@color/blue_medium"
android:text="@string/ok"
android:textSize="24dp"
android:clickable="true"
android:layout_marginLeft="64dp"
android:gravity="center"
android:textStyle="bold">
</TextView>
</LinearLayout>
</RelativeLayout>
这是目前的情况:
You can make it like below if you have
Drawable
of that. Just pass thatDrawable
reference in belowImageView
.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="25dp"
android:background="#111111">
<!--Your rest of xml code-->
</LinearLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="50dp"
android:src="@drawable/logo" />
</RelativeLayout>
Set
Height
andWidth
ofImage
as per your requirement.