Android如何制作此EditText的渐变

时间:2015-08-02 08:40:05

标签: java android css xml graphics

这个颜色代码是给我的:

background-image:-moz-linear-gradient(53% 0% -90deg,rgb(255,255,255) 0%,rgb(204,204,204) 100%); 
background-image:linear-gradient(-90deg,rgb(255,255,255) 0%,rgb(204,204,204) 100%);
width:787px;
height:142px;
border-color:rgb(221,221,221);
border-width:1px;
border-style:solid;

并要求this is a preview 我在edittext

的后台尝试此代码
 <?xml version="1.0" encoding="utf-8"?>
    <!--  res/drawable/rounded_edittext.xml -->
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" android:padding="10dp">
            <solid android:color="#FFFFFF"/>

            <corners
                android:bottomRightRadius="20dp"
                android:bottomLeftRadius="20dp"
                android:topLeftRadius="20dp"
                android:topRightRadius="20dp"/>
            <gradient
                android:startColor="#ffcccccc"
                android:centerColor="#e7e7e8"
                android:type="linear"
                android:endColor="#ffcccccc"
                android:angle="90" />
      <stroke android:color="#ffdddddd"
            android:width="2dp"/>
        </shape>

现在我想和图片一样但我不能得到它。 我怎么设置这个?

1 个答案:

答案 0 :(得分:0)

这是获得渐变的正确代码。

     <gradient android:startColor="#ffcccccc" 
android:type="linear"
  android:centerColor="#e7e7e8"
 android:endColor="#fff5f5f6" 
android:angle="90" /> 
相关问题