Muh*_*mar 2 java eclipse android android-layout
我正在尝试创建一个自定义对话框
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();
Run Code Online (Sandbox Code Playgroud)
背景图像有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>
Run Code Online (Sandbox Code Playgroud)
这就是我得到的.我怎么想删除对话框布局.白色的大边界.

不要使用AlertDialog.Builder.试试这个.
Dialog d = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
Run Code Online (Sandbox Code Playgroud)
要么
Dialog d = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
Run Code Online (Sandbox Code Playgroud)
您可以使用符合条件的任何主题,也可以创建自己的主题.请参阅此问题的答案和其他问题.另请参阅可用主题.
有关setContentView(),setCancelable(),show()以及您可能认为有用的其他方法的文档,请参阅Dialog.
你可以试试:
myDialog.show();
Window window = myDialog.getWindow();
window.setLayout(300, 300);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16303 次 |
| 最近记录: |