首页 > 解决方案 > Bottom Rounded Corners - Android

问题描述

I have been trying to fix this but for whatever I do, I just cannot get the Bottom Rounded Corners the way I want, I am using the following

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
      <shape android:shape="rectangle">
            <stroke android:width="0dp"  />
            <solid android:color="?attr/colorPrimaryDark"  />
      </shape>
   </item>
   <item android:top="0dp" android:bottom="1dp"> 
      <shape 
        android:shape="rectangle">
            <stroke android:width="0dp"/>
            <solid android:color="?attr/colorPrimary"/>
             <corners android:radius="15dp" android:bottomRightRadius="15dp" android:bottomLeftRadius="15dp" android:topLeftRadius="0dp" android:topRightRadius="0dp"/> 
        </shape>
   </item>
</layer-list> 

The Results are the following

Screenshot

It creates the corners but it adds grey color (colorPrimaryDark) to it where I want it to be white (colorPrimary") with a grey line - Any idea how I accomplish this?

标签: androidandroid-layout

解决方案


If you only want bottom border a Shape drawable will be enough . You do not need a layer-list for it . try this

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1dp" android:color="@color/green"/>
<solid android:color="?attr/colorPrimary" />
<corners
        android:bottomLeftRadius="15dp"
        android:bottomRightRadius="15dp" />
</shape>

The problem with your current code is first item have a solid color set . this is why the gray part showing .


推荐阅读