安卓:缩放一个可绘制或背景图像? [英] Android: Scale a Drawable or background image?

查看:116
本文介绍了安卓:缩放一个可绘制或背景图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个布局我要缩放的背景图像(保持其纵横比),获取创建页面时分配的空间。任何人有任何想法如何做到这一点?

On a layout I want to scale the background image (keeping its aspect ratio) to the space allocated when the page gets created. Anyone have any idea how to do this?

我使用layout.setBackgroundDrawable()和正在使用BitmapDrawable来setGravity的剪裁和填充,但没有看到任何缩放选项。

I am using layout.setBackgroundDrawable() and am using a BitmapDrawable to setGravity for clipping and filling, but don't see any option for scaling.

推荐答案

要自定义背景图片缩放创建这样的资源:

To customize background image scaling create a resource like this:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:gravity="center"
    android:src="@drawable/list_bkgnd" />

然后将集中在视图中,如果用作背景。还有其他的标志:<一href="http://developer.android.com/guide/topics/resources/drawable-resource.html">http://developer.android.com/guide/topics/resources/drawable-resource.html

这篇关于安卓:缩放一个可绘制或背景图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆