Comment créer une mise en page comme sur l'image?
Ce sera la ligne listview. fond orange est btn_default_small_selected:
android:background="@drawable/btn_default_small_selected"
Comment créer une mise en page comme sur l'image?
Ce sera la ligne listview. fond orange est btn_default_small_selected:
android:background="@drawable/btn_default_small_selected"
Quelque chose comme cela devrait vous approcher. Fondamentalement, vous définirez d'abord la boîte orange. Vous avez juste besoin d'un NinePatch pour que le dégradé orange soit défini comme arrière-plan TextView. Donnez-lui des marges (pour garder l'orange loin des bords), et un peu de rembourrage (pour garder le texte à l'écart du bord de la boîte orange). Ensuite, ajoutez le TextView pour "Palace", et alignez-le à gauche, et définissez le bord droit "toLeftOf" le premier TextView.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/gray_background_ninepatch"
>
<TextView
android:id="@+id/timetext"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:padding="8dp"
android:background="@drawable/orange_background_ninepatch"
android:text="1:25 - 4:50"
/>
<TextView
android:id="@+id/nametext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/timetext"
android:layout_alignParentLeft="true"
android:text="Palace"
/>
</RelativeLayout>
EDIT:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:gravity="center"
android:background="@drawable/gray_background_ninepatch"
>
<TextView
android:id="@+id/timetext"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:padding="8dp"
android:background="@drawable/orange_background_ninepatch"
android:text="1:25 - 4:50"
android:textStyle="bold"
android:textColor="@android:color/white"
/>
<ImageView
android:id="@+id/imageview"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:alignParentLeft="true"
android:src="@drawable/icon"
android:scaleType="fitCenter"
/>
<TextView
android:id="@+id/nametext"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_toLeftOf="@id/timetext"
android:layout_toRightOf="@id/imageview"
android:text="Palace"
android:textColor="@android:color/white"
/>
</RelativeLayout>
NinePatch:
Merci, @kcoppock. Si je dois ajouter ImageView sur le côté gauche, dois-je l'ajouter à la fin avec 'android: layout_toLeftOf =" @ id/nametext "' et android: layout_alignParentLeft = "true" '? –
Fermer! Mais vous voudrez réellement l'ajouter entre les deux TextViews, donnez-lui 'alignParentLeft' mais pas' toLeftOf'. Donnez ensuite à l'objet TextView un attribut 'toRightOf'' nametext' en référence à ImageView. – kcoppock
@kcoppock, l'image doit être à gauche: image, nom, heure. –
Alors, quelle est la question? Qu'est-ce que vous ne comprenez pas? – Egor
Comment créer un deuxième élément TextView avec une largeur fixe et situé à droite, quand le premier TextView devrait être situé à gauche et devrait prendre tout l'espace restant. –
Quelle partie avez-vous un problème avec? – jkhouw1