布局具有不同颜色 [英] Layout with different colors

查看:142
本文介绍了布局具有不同颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个 RelativeLayout的类似于下面的链接显示的图像的背景色。忽略黑线在底部图像的一半。

I'd like to have a background color of a RelativeLayout similar to that of an image shown in the link below. Ignore the black strip in the bottom half of the image.

我不希望使用的图像作为布局的背景。你能给我如何进行的想法?

I don't want to use the image as a background of the layout. Can you give me an idea of how to proceed?

推荐答案

您可以使用渐变。只要你想在选择设置不同梯度。完成!

You can use gradient. Set different gradient in selector as you want. Done!

<一个href="http://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html">GradientDrawable.class

这是你想要的,设置颜色。尽情享受吧!

This is what you want, set your colors. Enjoy!

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="30dp">
    <shape android:shape="rectangle" >
        <corners
        android:topRightRadius="8dip"
        android:topLeftRadius="8dip" />

    <gradient 
        android:startColor="#030303"
        android:endColor="#3B3B3B"
        android:angle="270" />
    </shape>
</item>
<item android:top="30dp" >
    <shape android:shape="rectangle" >
        <corners
        android:bottomLeftRadius="8dip"
    android:bottomRightRadius="8dip" />

    <gradient 
        android:startColor="#4B5057"
        android:endColor="#4B5059"
        android:angle="270" />
    <size android:height="30dp" />
    </shape>
</item>
</layer-list>

这篇关于布局具有不同颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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