2016-03-24 16 views
7

Kullanıcı girişine bağlı olarak farklı parçaları tutmak için kullanıyorum kök görünümü (lineer: dikey) içinde bir FrameLayout var. FrameLayout arka plandan daha küçüktür, dolayısıyla "kayan" görünür.Yuvarlatılmış köşeli FrameLayout

FrameLayout öğelerinin köşelerini nasıl doyarım?

FrameLayout içine giren parçacıklar resim değil, bu yüzden onları kırpamıyorum.

+0

Sadece FrameLayout öğesinin arka planı olarak elle hazırlanmış bir çizimde atılmıyor musunuz? – m02ph3u5

+0

Bunu kontrol edin http://www.gadgetsaint.com/tips/rounded-corners-views-layouts-android/#.WPz2QVN97BI – ASP

cevap

11

Bir xml dosyası oluşturun, ör. your_rounded_shape.xml, ve çekilebilir klasörde aşağıdaki kodu ekleyin:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#CCCCCC"/>  

    <stroke android:width="2dp" 
     android:color="#999999"/> 

    <padding android:left="2dp" 
     android:top="2dp" 
     android:right="2dp" 
     android:bottom="2dp"/> 

    <corners android:bottomRightRadius="8dp" 
     android:bottomLeftRadius="8dp" 
     android:topLeftRadius="8dp" 
     android:topRightRadius="8dp"/> 
</shape> 

Sonra FrameLayout bir arka plan olarak your_rounded_shape.xml kullanın. Böyle bir şey:

<FrameLayout 
    android:width="match_parent" 
    android:height="wrap_content" 
    android:background="your_rounded_shape"/> 
+0

Bu mükemmel! Teşekkür ederim, tam olarak aradığım şey bu. –

İlgili konular