2017-05-13 2 views
0

My appWie füge ich PNG-Datei und Rahmen in Android-Schaltfläche hinzu?

hier für die gemischte Button habe ich

<?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> 

verwendet und für andere Tasten habe ich verwendet

<?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> 

Nun ich den schwarzen Rand um die gemischte Schaltfläche hinzufügen mag, wie machen?

Antwort

0

Verwenden Form in Ebenenliste unter Punkt in XML-Datei wie unten

<?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> 

Es Sie ..

Referenz How overlay bitmap and shape in layer-list properly

+0

Aber die oberen linken und unteren linken Ecken scheint nicht zu funktionieren. Irgendeine Lösungsmöglichkeit? –

+0

Danke. Aber keine Ahnung, wie man Ecken in die "@ drawable/stripes" einfügt ?? Aus diesem Grund scheinen die Ecken der Form nicht zu funktionieren! –

0

Sie sind ganz nah helfen werden, Sie müssen nur noch hinzufügen die Form (für Ihre Grenze) zum <layer-list>

Etwas wie dieses:

<?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

Danke. Aber keine Ahnung, wie man Ecken in die "@ drawable/stripes" einfügt ?? Aus diesem Grund scheinen die Ecken der Form nicht zu funktionieren! –

Verwandte Themen