2013-09-22 21 views
2

我试图用3种或更多种颜色完成单线背景,我想知道它是否可能与xml形状或我必须使用9个补丁?我是一个有形状的新手,我花了整整一个早上试图完成我想要的,但没有。多色线与形状

下面是我想达到的目标:

enter image description here

我媒体链接试过这种形状与梯度,但它只是假设起始色

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- This is the line --> 
<item> 
     <shape> 
      <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="1dp"/> 
      <solid android:color="#868686" /> 
     </shape> 
</item> 
<!-- This is the main color --> 
<item> 
    <shape> 
     <solid android:color="@android:color/white" /> 
    </shape> 
</item> 

解决方案Update

除了SAM提供的答案,我发现9.png是我的问题的最佳答案。我简单地创建一个png与3种颜色,然后应用九个补丁和DONE:D我用这个工具weblookandfeel。 com/nine-patch-editor就像在应用程序中打开图像并保存,并且您拥有9.png一样简单。

+0

'layer-list'将把形状/物品放在其他物体上。 – gunar

回答

1

你可以尝试使用这个工具,你要得到的颜色, http://angrytools.com/gradient/

,然后在横向排列的思路之一可能是,创建三个可绘和使用线性布局安排他们

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 

    <ImageView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/image1"/> 
    <ImageView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/image2"/> 
    <ImageView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/image3"/> 

</LinearLayout> 
+0

邑你是对的这是一种方式,但很难,我简单地创建一个与3种颜色的PNG我想申请九个补丁来创建一个9.png和voilá完成:D九个补丁这是真棒:D顺便说一句,我有使用这个工具http://weblookandfeel.com/nine-patch-editor/就像在应用程序中打开图像并保存并且您有9.png一样简单,但我会接受您的答案,因为这是一个有效的解决方案,谢谢; ) – firetrap