在android中创建渐变边框?

在android中创建渐变边框?,android,border,Android,Border,如何创建下图所示的渐变边框 您可以通过使用分层列表和填充来实现这一点。您将需要3个元素: 1:border.xml形状,它只是边框颜色的实心形状:border.xml <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#ff0000"/> </

如何创建下图所示的渐变边框


您可以通过使用分层列表和填充来实现这一点。您将需要3个元素:

1:border.xml形状,它只是边框颜色的实心形状:border.xml

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ff0000"/>
</shape>

将其设置为文本视图、布局等的背景(您希望笔划出现的位置)

或者只是创建一个带有边框的图像

你觉得这个怎么样?
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#00ff00"/>
</shape>
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/border"/>
<item android:drawable="@drawable/inner"
android:top="3dp" android:right="0dp" android:bottom="3dp"
android:left="3dp" />