【发布时间】:2014-06-25 07:46:45
【问题描述】:
我想知道这种渐变色在android中是否可行? 如果可能,那怎么办? http://www.techandall.com/wp-content/uploads/2013/10/techandall_mobile-analytics-UI-concept_preview1.jpg
谢谢, 布斯卡尼亚。
【问题讨论】:
标签: android colors gradient shape
我想知道这种渐变色在android中是否可行? 如果可能,那怎么办? http://www.techandall.com/wp-content/uploads/2013/10/techandall_mobile-analytics-UI-concept_preview1.jpg
谢谢, 布斯卡尼亚。
【问题讨论】:
标签: android colors gradient shape
这里有一个为 android 创建渐变形状的在线工具:
http://angrytools.com/gradient/
通过点击 android 选项卡,您将获得带有形状的 xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="linear"
android:centerX="47%"
android:startColor="#FF70C1FF"
android:centerColor="#FFBDC9FF"
android:endColor="#FF734080"
android:angle="45"/>
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="radial"
android:centerX="50%"
android:centerY="50%"
android:startColor="#FF70C1FF"
android:centerColor="#FFBDC9FF"
android:endColor="#FF734080"
android:gradientRadius="47"/>
</shape>
【讨论】:
int startColor=Color.parseColor("#a6c1de");
//you can add as many gradient colors as you want here
//and include it in the int array while initializing GradientDrawable
int endColor=Color.parseColor("#aa82b7");
GradientDrawable mDrawable=new GradientDrawable(Orientation.LEFT_RIGHT,
new int[] {startColor,endColor});
LinearLayout mLayout=(LinearLayout)findViewById(R.id.your_id);
mLayout.setBackgroundDrawable(mDrawable);
【讨论】:
new int[] startColor,centerColor, endColor}
您不能使用多种颜色来创建Gradient,就像您的图像中两种颜色呈线性一样。所以你应该使用图像而不是渐变。
【讨论】: