布局具有不同颜色不同颜色、布局

2023-09-04 13:14:13 作者:一段情,一段悲

我想有一个 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!

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>
 
精彩推荐
图片推荐