2017-01-06 2 views

Répondre

1

Le mot-clé de recherche est: "Android comment créer des formes personnalisées".

Vous trouverez de nombreux exemples. Par exemple this un.

Si vous imagé cette forme ce que vous voulez est un rectangle régulier + un triangle vous obtenez le résultat du lien fourni, il suffit d'adapter les paramètres.

altered image

J'espère est obligeamment!

0

Vous pouvez essayer ce code:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 

<!-- Colored rectangle--> 
<item> 
    <shape android:shape="rectangle"> 
     <size 
      android:width="100dp" 
      android:height="40dp" /> 
     <solid android:color="#13a89e" /> 
    </shape> 
</item> 

<!-- This rectangle for the left side --> 
<!-- Its color should be the same as layout's background --> 
<item 
    android:right="100dp" 
    android:left="-100dp" 
    android:top="-100dp" 
    android:bottom="-100dp"> 
    <rotate 
     android:fromDegrees="45"> 
     <shape android:shape="rectangle"> 
      <solid android:color="#13a89e" /> 
     </shape> 
    </rotate> 
</item> 

<!-- This rectangle for the right side --> 
<!-- Their color should be the same as layout's background --> 
<item 
    android:right="-100dp" 
    android:left="100dp" 
    android:top="-100dp" 
    android:bottom="-100dp"> 
    <rotate 
     android:fromDegrees="45"> 
     <shape android:shape="rectangle"> 
      <solid android:color="#ffffff" /> 
     </shape> 
    </rotate> 
</item> 

et MISE EN PAGE

<View 
    android:layout_centerInParent="true" 
    android:layout_width="100dp" 
    android:layout_height="40dp" 
    android:background="@drawable/filename"/>