安卓:缩放一个可绘制或背景图像?缩放、图像、背景

由网友(纵使我眉目清秀也未如你眼)分享简介:在一个布局我要缩放的背景图像(保持其纵横比),获取创建页面时分配的空间。任何人有任何想法如何做到这一点?On a layout I want to scale the background image (keeping its aspect ratio) to the space allocated when the...

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

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" />

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

阅读全文

相关推荐

最新文章