如何调整位图 [英] How to resize bitmap

查看:172
本文介绍了如何调整位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现到旋转器的风格,但三角图标变为太大,怎么可以控制其尺寸???

I want to implement to spinner a style , but triangle icon goes too big , how is possible to control its dimension ???

style.xml

style.xml

    <item name="android:background">@drawable/gradient_spinner</item>
    <item name="android:layout_marginLeft">10dp</item>
    <item name="android:layout_marginRight">10dp</item>
    <item name="android:layout_marginBottom">10dp</item>
    <item name="android:paddingLeft">8dp</item>
    <item name="android:paddingTop">5dp</item>
    <item name="android:paddingBottom">5dp</item>
    <item name="android:popupBackground">#DFFFFFFF</item>
</style>

gradient_spinner.xml

gradient_spinner.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <layer-list>
            <item>
                <shape>
                    <gradient android:angle="90" android:endColor="#ffffff" android:startColor="#ffffff" android:type="linear" />

                    <stroke android:width="1dp" android:color="#ffffff" />

                    <corners android:radius="4dp" />

                    <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
                </shape>
            </item>
            <item android:drawable="@drawable/spinner_arrow"
                android:gravity="bottom|right"
                />
        </layer-list>
    </item>
</selector>

如何在此刻看上去坡度微调
http://imgur.com/bwKEoo2

推荐答案

您可以使用Java code调整位图。结果

you can resize bitmap using java code.

Bitmap bitmap;
int height = (bitmap.getHeight() * 512 / bitmap.getWidth());
Bitmap scale = Bitmap.createScaledBitmap(bitmap, 512,height, true);
image.setImageBitmap(scale);

这篇关于如何调整位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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