2012-06-04 19 views
3

我想要得到類似於您可以在下面看到的形狀。我缺少的是標題顏色(匿名文本背後的顏色)。我已經轉載了什麼,我想通過簡單的移動在第二TextView的鼠標這是現在突出,使這種效果:)如何讓這樣的形狀?

當前代碼:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<stroke android:width="2dp" android:color="#000000" /> 
<gradient android:startColor="#898989" android:endColor="#B5B5B5" android:angle="270"/> 

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

enter image description here

回答

2

您需要使用Layer List那包含兩個drawable。

例如,首先會覆蓋整個形狀,並且所述第二將覆蓋它,但與android:top="10dp"集合,以創建一個偏移量示出了下面的第一形狀

編輯:
像這樣:

<?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="2dp" 
       android:color="#000000" /> 

      <solid android:color="#00ff00" /> 

      <corners 
       android:bottomLeftRadius="7dp" 
       android:bottomRightRadius="7dp" /> 
     </shape> 
    </item> 
    <item 
     android:bottom="2dp" 
     android:left="2dp" 
     android:right="2dp" 
     android:top="20dp"> 
     <shape android:shape="rectangle" > 
      <gradient 
       android:angle="270" 
       android:endColor="#B5B5B5" 
       android:startColor="#898989" /> 

      <corners 
       android:bottomLeftRadius="7dp" 
       android:bottomRightRadius="7dp" /> 
     </shape> 
    </item> 
</layer-list> 
+0

謝謝,這看起來甚至更好的解決方案。 –

+0

......但這並不完全正常 - 現在我也在整個標題中敲擊!是否可以將描邊僅設置爲左邊界,頂部邊界和右邊界? –

+0

沒問題,我做了一個編輯。 (從第二個形狀中刪除筆畫,並在筆畫的大小中添加項目偏移量) – eladr

1

使用LinearLayout並將兩個不同形狀的TextView作爲背景。

第一個上角落圓角,第二個下角落。

+0

謝謝,我現在覺得啞巴:) –

相關問題