Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

android - Border in shape XML

I am trying to make a drawable to use for a button. I would like it to have this coloring, with a 2px border around it.

Everything works just fine except I cannot get the border to show up...

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <gradient android:startColor="@color/bar_clicked_dark"
        android:endColor="@color/bar_clicked_light"
        android:angle="90"/>

    <corners android:bottomLeftRadius="0dp"
        android:topLeftRadius="15dp"
        android:bottomRightRadius="15dp"
        android:topRightRadius="0dp" />

    <stroke android:width="2dp" 
        color="#ff00ffff" />

</shape>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It looks like you forgot the prefix on the color attribute. Try

 <stroke android:width="2dp" android:color="#ff00ffff"/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...