2015-06-01 56 views
-1

对不起,我的英语。我无法理解半径的工作。我需要创建一个透明的图形来存储文本。项目半径形状android

enter image description here

下面我创建了一个数字,但在左上角圆角不起作用

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 



    <item android:top="-1dp" android:right="-1dp" android:left="-1dp" android:bottom="-1dp"> 
     <shape> 

      <stroke 

       android:width="1dp" 
       android:color="#ababb2" /> 
     </shape> 
    </item> 

</layer-list> 

如果我使用的角落

<corners android:radius="1dp" 
    android:bottomRightRadius="2dp" android:bottomLeftRadius="0dp" 
    android:topLeftRadius="2dp" android:topRightRadius="0dp"/> 

一个数字四舍五入大家,不只是我需要的角度

+0

这种小半径将不显着的。尝试8dp或16 dp。无论如何,角度是90°。 –

+2

你只需要'android:topLeftRadius =“2dp”',摆脱其他人 – Blackbelt

回答

2

试试这个:

创建res/drawable一个XML文件名为rounded_corner.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <corners 
     android:bottomRightRadius="0dp" android:bottomLeftRadius="0dp" 
     android:topLeftRadius="5dp" android:topRightRadius="0dp"/> 
</shape> 

然后,绘制适用于您的视图的背景一样:

<TextView android:id="@+id/example" 
    android:width="wrap_content" 
    android:height="wrap_content" 
    android:background="@drawable/rounded_corner"/>