首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将布局背景图像调整为centerInside?

如何将布局背景图像调整为centerInside?
EN

Stack Overflow用户
提问于 2014-06-12 12:27:51
回答 3查看 70关注 0票数 0

当将图像指定为布局的背景时,拉伸到整个布局,但我想使该背景图像在中以为中心,就像在ImageButtons中那样:

代码语言:javascript
运行
复制
android:scaleType="centerInside"

LinearRelative布局中有实现这一目标的方法吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-06-12 12:34:51

你应该试试..。

1.)以RelativeLayout属性matchParent为例。和centerInparent=true

2.)在it属性WrapContent中取一个WrapContent。现在看一下造币视图的背景或背景。

票数 1
EN

Stack Overflow用户

发布于 2014-06-12 12:37:46

您可以在LayoutB中使用另一个布局LayoutA。并将宽度和高度设置为wrap_content of LayoutB..and,将图像设置为LayoutB..and的背景,并设置如下所示的分布:

代码语言:javascript
运行
复制
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
票数 1
EN

Stack Overflow用户

发布于 2014-06-12 12:38:03

这会帮你的

代码语言:javascript
运行
复制
<?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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24184418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档