2015-08-05 11 views
7

Oto fragment znaczników do rysowania prostokąta z czterema zaokrąglonymi narożnikami:Jak narysować prostokąt z zaokrąglonymi rogami przy użyciu XML?

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 

    <solid android:color="#fff"></solid> 

    <padding 
     android:bottom="5dp" 
     android:left="-1dp" 
     android:right="-1dp" 
     android:top="5dp"></padding> 

    <corners android:radius="2dp"></corners> 

</shape> 

Ale jeśli chcę zaokrąglić narożniki tylko z jednej strony (dwa narożniki), jak mogę to zrobić?

Dzięki.

+0

< rogi android: bottomRightRadius =" 0DP” android: bottomLeftRadius = "0DP" android: topLeftRadius = "15dp" android: topRightRadius = "15dp"/> Kushan2

Odpowiedz

12
<corners 
    android:bottomLeftRadius="2dp" 
    android:bottomRightRadius="2dp" 
    android:topLeftRadius="2dp" 
    android:topRightRadius="2dp" /> 
+0

Idealnie działa! Dzięki! –

0

Wykonaj to z wymaganiem.

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

lub

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

lub inny efekt ten pokazują uruchomieniu czas. Maj w pliku xml pokazuje całą rundę.

2

Tworzenie czerpalnych stanie zasobu: -

<?xml version="1.0" encoding="utf-8"?> 
<!-- res/drawable/rounded_edittext.xml --> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" android:padding="10dp"> 
<solid android:color="#FFFFFF"/> 
<corners 
android:bottomRightRadius="15dp" 
android:bottomLeftRadius="15dp" 
android:topLeftRadius="15dp" 
android:topRightRadius="15dp"/> 
</shape> 

ustawiona powyżej w tle dowolnym widoku.

Powiązane problemy