Android的形状边界梯度 [英] Android shape border with gradient
本文介绍了Android的形状边界梯度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个边界的LinearLayout中。所以,我决定创建一个形状。我想边境有一个梯度。以下是没有这样做。它填补了矩形,然后创建一个中风。我不想填充的矩形,只是行程。我想渐变适用于中风。
<?XML版本=1.0编码=UTF-8&GT?;
<形状的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:形状=矩形> <梯度
机器人:角=360
机器人:centerColor =#e95a22
机器人:ENDCOLOR =#ff00b5
机器人:gradientRadius =360
机器人:startColor =#006386
机器人:TYPE =扫荡/> <中风
机器人:宽=2DP
机器人:颜色=#ff207d94/>< /形状>
解决方案
尝试是这样的:
<?XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android> <项目>
<形状机器人:形状=矩形>
<梯度
机器人:角=360
机器人:centerColor =#e95a22
机器人:ENDCOLOR =#ff00b5
机器人:gradientRadius =360
机器人:startColor =#006386
机器人:TYPE =扫荡/> <中风
机器人:宽=2DP
机器人:颜色=#ff207d94/>
< /形状>
< /项目>
<项目
机器人:底部=2DP
机器人:左=2DP
机器人:右=2DP
机器人:顶部=2DP>
<形状机器人:形状=矩形>
[固体机器人:颜色=#FFF/>
< /形状>
< /项目>< /层列表>
I want to create a border for a linearLayout. So I decide to create a shape. I want the border to have a gradient. The following is not doing it. It fills the rectangle and then creates a stroke. I don't want a filled rectangle, just the stroke. And I want to apply the gradient to the stroke.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="360"
android:centerColor="#e95a22"
android:endColor="#ff00b5"
android:gradientRadius="360"
android:startColor="#006386"
android:type="sweep" />
<stroke
android:width="2dp"
android:color="#ff207d94" />
</shape>
解决方案
try something like this:
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<gradient
android:angle="360"
android:centerColor="#e95a22"
android:endColor="#ff00b5"
android:gradientRadius="360"
android:startColor="#006386"
android:type="sweep" />
<stroke
android:width="2dp"
android:color="#ff207d94" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp">
<shape android:shape="rectangle" >
<solid android:color="#fff" />
</shape>
</item>
</layer-list>
这篇关于Android的形状边界梯度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文