Question

Je suis un style un bouton dont la largeur peut changer dans le programme par le biais de contenu différent. Je suis les fichiers .png du concepteur comme ceci:

[Left Border] [Background (just a strip with the gradient)] [Right Border]

Je pensais que je suis très bien avec l'affectation des propriétés du bouton comme ceci:

Background: Background.png
Drawable left: LeftBorder.png
Drawable right: RightBorder.png

MAIS il ne sera pas comme ça;) En ce moment, le background.png commence là où commence la Drawable gauche et se termine à la fin de Drawable droit. Est l'utilisation de ces propriétés Drawable pas la bonne façon dans ce cas?

Voici le code:

<Button
  android:text="@+id/Button01"
  android:id="@+id/Button01"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:drawableLeft="@drawable/top_loaction_left"
  android:drawableRight="@drawable/top_loaction_right"
  android:background="@drawable/top_loaction_bg"></Button>

..

Était-ce utile?

La solution

Qu'est-ce que vous avez besoin est une image de patch 9.

http://developer.android.com/guide/developing/tools /draw9patch.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top