Как создать макет как на картинке? - PullRequest
0 голосов
/ 21 мая 2011

enter image description here

Это будет строка просмотра списка.Оранжевый фон: btn_default_small_selected:

android:background="@drawable/btn_default_small_selected" 

1 Ответ

1 голос
/ 21 мая 2011

Нечто подобное должно сблизить вас. По сути, вы сначала определите оранжевую рамку. Вам просто нужно NinePatch для оранжевого градиента, чтобы установить в качестве фона TextView. Дайте ему несколько полей (чтобы апельсин не попадал на края) и отступы (чтобы текст не попал на край оранжевого поля). Затем добавьте TextView для «Palace», выровняйте его по левому краю и установите правый край «toLeftOf» для первого 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>

enter image description here

NinePatch: enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...