如何使用位图作为背景的​​Andr​​oid从LinearLayout中去除黑边? [英] How to remove black bars from LinearLayout using Bitmap as background in Android?

查看:174
本文介绍了如何使用位图作为背景的​​Andr​​oid从LinearLayout中去除黑边?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

![当前布局] http://i50.tinypic.com/qqznzs.png

我试图获得从布局的顶部和底部的blakc杆是白色,而不是黑色的。我曾尝试已经在改变背景颜色。

I am trying to get the blakc bars from the top and bottom of the layout to be white instead of black. I have tried changing the background color already.

可绘制code:

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

主要code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/startup"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

BTW我需要的图像不是垂直拉伸,因此更改这不是一个所需的解决方案无论是。

BTW I need the image to not stretch vertically, so changing that isn't a needed solution either.

推荐答案

这些黑网吧的背景为主题的只是颜色。要摆脱他们,你可以改变你的位图绘制是一个图层列表与白色的背景颜色,像这样:

Those black bars are just the color of the background for the theme. To get rid of them, you can change your bitmap drawable to be a layer list with a background color of white like so:

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

    <item>
        <color android:color="@android:color/white"/>
    </item>

    <item>
        <bitmap android:gravity="clip_horizontal|clip_vertical|center"
            android:src="@drawable/theblindgoat_logo"
            android:tileMode="disabled" />
    </item>

</layer-list>

这篇关于如何使用位图作为背景的​​Andr​​oid从LinearLayout中去除黑边?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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