如何使android的对话框的背景图片无法展开对话? [英] How to make dialog background image not expand dialog in android?
问题描述
在我的Android项目,当我设置背景为XML code的对话(对话使用XML文件布局),对话窗口的大小增加它适合的背景图像。
In my android project, when I set a background for a dialog in the xml code (the dialog uses a xml file for the layout), the dialog window size increases to fit the background image in it.
我如何设置它,使窗口的大小不会增加。它只是忽略了将不会出现在对话框中的背景部分。我猜图像的锚可以是中心或左上角,无所谓。
How can I set it so that the window size does not increase. It just ignores the background part that won't appear in the dialog. I guess the anchor of the image can be the center or the top left, doesn't matter.
有谁知道如何做到这一点?
Does anyone know how to do this?
感谢。
推荐答案
我找到了解决办法,在这里看到:<一href=\"http://stackoverflow.com/questions/25626144/scale-down-or-crop-dialog-background-in-android/25627385\">Scale向下(或作物)对话框的背景Android中
I found the solution, see here: Scale down (or crop) dialog background in Android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:src="@drawable/back_dialog"
android:scaleType="fitXY"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignTop="@+id/dialog_layout_main"
android:layout_alignBottom="@id/dialog_layout_main"
android:layout_alignLeft="@id/dialog_layout_main"
android:layout_alignRight="@id/dialog_layout_main" />
<LinearLayout
android:id="@+id/dialog_layout_main"
android:layout_width="match_parent"
android:layout_height="wrap_content">
.........
</LinearLayout>
</RelativeLayout>
这篇关于如何使android的对话框的背景图片无法展开对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!