【发布时间】:2018-05-30 06:53:38
【问题描述】:
所需的输出图像:
我已经尝试了代码,我的输出是这样的。请帮助我生成我所展示的输出。
我的代码:
活动中:
@OnClick(R.id.imageView)
void imageTapped() {
Dialog alertDialog = new Dialog(this);
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
alertDialog.setContentView(R.layout.photo_dialog);
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
alertDialog.show();
}
在 XML (R.layout.photo_dialog) 中:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabLayout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:background="@android:color/transparent">
<Button
android:id="@+id/btn1"
android:layout_width="@dimen/_200sdp"
android:layout_height="wrap_content"
android:background="#3ca49c"
android:paddingBottom="@dimen/activity_margin_half"
android:paddingLeft="@dimen/_40sdp"
android:paddingRight="@dimen/_40sdp"
android:paddingTop="@dimen/activity_margin_half"
android:text="Take Photo"
android:layout_marginBottom="@dimen/_20sdp"
android:layout_centerHorizontal="true"
android:textColor="@color/white"/>
<Button
android:id="@+id/btn2"
android:layout_width="@dimen/_200sdp"
android:layout_height="wrap_content"
android:background="#3ca49c"
android:paddingBottom="@dimen/activity_margin_half"
android:paddingLeft="@dimen/_40sdp"
android:paddingRight="@dimen/_40sdp"
android:paddingTop="@dimen/activity_margin_half"
android:text="Choose Existing"
android:layout_below="@id/btn1"
android:layout_marginBottom="@dimen/_20sdp"
android:layout_centerHorizontal="true"
android:textColor="@color/white"/>
<Button
android:id="@+id/btn3"
android:layout_width="@dimen/_200sdp"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingBottom="@dimen/activity_margin_half"
android:paddingLeft="@dimen/_40sdp"
android:paddingRight="@dimen/_40sdp"
android:layout_below="@id/btn2"
android:layout_marginBottom="@dimen/_40sdp"
android:paddingTop="@dimen/activity_margin_half"
android:text="Cancel"
android:layout_centerHorizontal="true"
android:textColor="#3ca49c"/>
</RelativeLayout>
我的输出:
我需要一个白色透明背景和所需输出图像中所示的对齐方式。请帮我提些建议。
【问题讨论】:
标签: android android-layout android-activity dialog android-alertdialog