2017-05-13 8 views
0
ここ

My appアンドロイドボタンでpngファイルとボーダーの両方を追加するには?

、私は

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <bitmap 
     android:src="@drawable/stripes" 
     android:tileMode="repeat" 
     android:dither="true" 
     android:antialias="true" /> 
</item> 
</layer-list> 

そして、私は

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <gradient android:startColor="@android:color/transparent" 
    android:endColor="@android:color/transparent" 
    android:angle="270" /> 
    <corners android:radius="3dp" /> 
    <stroke android:width="5px" android:color="#000000" /> 
</shape> 

を使用している他のボタンのために使用している混合ボタンの今、私はどのように混合ボタンの周りにその黒い境界線を追加したいです何をする?あなたはスーパー近くにある

答えて

0

xmlファイル内の項目の下のレイヤーリストで使用形状にそれはあなたをお手伝いします

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <bitmap 
      android:src="@drawable/stripes" 
      android:tileMode="repeat" 
      android:dither="true" 
      android:antialias="true" /> 
    </item> 
    <item> 
     <shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
      <gradient android:startColor="@android:color/transparent" 
         android:endColor="@android:color/transparent" 
         android:angle="270" /> 
      <corners android:radius="3dp" /> 
      <stroke android:width="5px" android:color="#000000" /> 
     </shape> 
    </item> 
</layer-list> 

以下のように...

参照How overlay bitmap and shape in layer-list properly

+0

ただし、左上隅と左下隅は機能していないようです。どんな解決策ですか? –

+0

ありがとうございます。しかし、どのように "@ drawable/stripes"にコーナーを追加するかについての考え方はありますか?このため、形の角がうまくいかないようです! –

0

、あなただけ追加する必要があります図形(あなたの国境のため)を<layer-list>

何かのように:

<?xml version="1.0" encoding="utf-8"?> 

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <bitmap 
      android:src="@drawable/stripes" 
      android:tileMode="repeat" 
      android:dither="true" 
      android:antialias="true" /> 
    </item> 
    <item> 
     <shape xmlns:android="http://schemas.android.com/apk/res/android" 
      android:shape="rectangle"> 
       <gradient android:startColor="@android:color/transparent" 
        android:endColor="@android:color/transparent" 
        android:angle="270" /> 
     <corners android:radius="3dp" /> 
     <stroke android:width="5px" android:color="#000000" /> 
     </shape>  
    </item> 
</layer-list> 
+0

ありがとうございます。しかし、どのように "@ drawable/stripes"にコーナーを追加するかについての考え方はありますか?このため、形の角がうまくいかないようです! –

関連する問題