Aks*_*thi 11 android android-layout customdialog
我想创建一个自定义对话框,其布局如图所示.
交叉/关闭按钮必须位于右上方.请建议我如何实现这种布局.
提前致谢.
Pin*_*nki 21
可能在代码下面对你有用,就像这样实现
<?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:layout_gravity="center_vertical"
android:gravity="center"
android:orientation="vertical" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:background="@drawable/popup_password_latest"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="-50dp" >
<!---add your views here-->
</LinearLayout>
<ImageView
android:id="@+id/imageView_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:clickable="true"
android:src="@drawable/close_selector" />
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
相对布局将是你的父母一个,然后添加关闭按钮应用android:layout_alignParentRight="true"和 android:layout_alignParentTop="true"甚至放弃在减去右边和顶边按您的要求.
码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/relativeLayout1"
android:layout_width="255dp"
android:layout_height="385dp"
android:layout_centerInParent="true"
android:background="@color/white"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="@+id/button_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/relativeLayout1"
android:layout_alignTop="@+id/relativeLayout1"
android:layout_marginRight="-10dp"
android:layout_marginTop="-10dp"
android:background="@drawable/close" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
产量

| 归档时间: |
|
| 查看次数: |
28938 次 |
| 最近记录: |