2015-06-01 55 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"/>