round corners with border color

前端 未结 2 769
旧巷少年郎
旧巷少年郎 2021-02-05 04:11

I am using the following code to get rounded corners as well as a colored outline:

 

相关标签:
2条回答
  • 2021-02-05 04:59

    Use the <shape> tag to create a drawable in XML with rounded corners. (You can do other stuff with the shape tag like define a color gradient as well).

    Following code may help you:

    <?xml version="1.0" encoding="UTF-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#ffffffff"/>    
    
    <stroke android:width="3dp"
            android:color="#ff000000"
            />
    
    <padding android:left="1dp"
             android:top="1dp"
             android:right="1dp"
             android:bottom="1dp"
             /> 
    
    <corners android:bottomRightRadius="7dp" 
             android:bottomLeftRadius="7dp" 
             android:topLeftRadius="7dp"
             android:topRightRadius="7dp"/> 
    </shape>
    
    0 讨论(0)
  • 2021-02-05 05:06

    Use this customize according to your need.

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="@android:color/transparent" />
        <stroke
            android:width="4dp"
            android:color="@android:color/holo_blue_light" />
        <corners android:radius="6dp" />
    </shape>
    
    0 讨论(0)
提交回复
热议问题