Sna*_*ake 11 android android-dialog
我正在使用Android SDK制作游戏.一路上,我需要显示弹出/对话框,就像用户可以升级的任何其他游戏一样.我遇到的问题是对话框的大小.我正在使用RelativeLayout,我正在使用"wrap_content"将背景设置为我的图像.
对话框占用内部视图大小(或Android设置的默认对话框最小大小,以较大者为准)的问题不是背景图像.如果我使用fill_parent,那么它会拉伸它.我花了几个小时和几个小时旋转我,我似乎无法找到一个有效的方式,窗口的大小与背景图像的大小相匹配
有什么建议?这是一个非常常见的用例,必须有办法!谢谢
这是一些布局内容
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/popup"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/ibCloseDialog"
android:background="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/close" />
<Button
android:id="@+id/b1"
android:background="@drawable/blue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/b2"
android:text="b1" />
<Button
android:id="@+id/b2"
android:background="@drawable/blue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="b2" />
<Button
android:id="@+id/b3"
android:background="@drawable/blue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/b2"
android:text="b2" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
您是否在RelativeLayout中使用属性“android:background”?如果是这种情况,您可以尝试这样做:
<RelativeLayout
.
.
.
>
<ImageView
android:layout_width="MATCH_PARENT"
android:layout_height="MATCH_PARENT"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/yourDrawable" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
还:
| 归档时间: |
|
| 查看次数: |
1253 次 |
| 最近记录: |