我试图做一个自定义对话框自定义对话框的宽度和高度
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.rate_layout, null);
RelativeLayout rate = (RelativeLayout) view.findViewById(R.id.rateClick);
RelativeLayout close = (RelativeLayout) view.findViewById(R.id.closeBtn);
close.setClickable(true);
rate.setClickable(true);
final AlertDialog.Builder dd = new AlertDialog.Builder(this);
dd.setView(view);
dd.setCancelable(false);
final AlertDialog d = dd.create();
d.show();
背景图像有4种分辨率的,所以我只能做wrap content
。
这里是我的xml文件
<?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"
>
<RelativeLayout
android:id="@+id/rateClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@drawable/rate_now_button" />
<RelativeLayout
android:id="@+id/imageView1"
android:layout_width="219dp"
android:layout_height="234dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/pop_up" >
<RelativeLayout
android:id="@+id/closeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/close_button" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/rateClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:background="@drawable/rate_now_button" />
</RelativeLayout>
</RelativeLayout>
这是我得到。我想如何删除对话框布局。白色的大边框。
http://www.mkyong.com/android/android-custom-dialog-example/ –
http://codinglookseasy.blogspot.in/2012/07/alert-box-code.html –
了现在也有这个问题一段时间了。我在宽度和高度上使用'wrap_content',但也是一个很好的答案,您的问题也会对我有所帮助。 – cosmincalistru