当将图像指定为布局的背景时,将拉伸到整个布局,但我想使该背景图像在中以为中心,就像在ImageButtons
中那样:
android:scaleType="centerInside"
在Linear
或Relative
布局中有实现这一目标的方法吗?
发布于 2014-06-12 12:34:51
你应该试试..。
1.)以RelativeLayout属性matchParent为例。和centerInparent=true
2.)在it属性WrapContent中取一个WrapContent。现在看一下造币视图的背景或背景。
发布于 2014-06-12 12:37:46
您可以在LayoutB中使用另一个布局LayoutA。并将宽度和高度设置为wrap_content of LayoutB..and,将图像设置为LayoutB..and的背景,并设置如下所示的分布:
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
发布于 2014-06-12 12:38:03
这会帮你的
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/someImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/someImageSrc" />
</RelativeLayout>
https://stackoverflow.com/questions/24184418
复制相似问题