Android RelativeLayout проблемы - PullRequest
       1

Android RelativeLayout проблемы

0 голосов
/ 12 февраля 2012

Я довольно новичок в относительных раскладках и борюсь с ними;)

Я пытаюсь сделать следующее: http://pineapple.cc/plan.jpg

Но я получаю вот что:1006 *http://pineapple.cc/result.jpg

Это мой код:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
    <ImageView 
        android:id="@+id/list_poi_image"
        android:src="@drawable/ic_launcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@+id/list_poi_ll"
        android:background="#000000" />
    <LinearLayout
        android:id="@+id/list_poi_ll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:orientation="vertical">
        <RelativeLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView android:id="@+id/list_poi_name"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/list_poi_date_created"
                android:text="Name"/>
             <TextView android:id="@+id/list_poi_date_created"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:text="Date created"/>
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <TextView android:id="@+id/list_poi_description"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/list_poi_date_planned"
                android:text="Description"/>
             <TextView android:id="@+id/list_poi_date_planned"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:text="Date planned"/>
        </RelativeLayout>
    </LinearLayout>
</RelativeLayout>

Что я делаю не так ???

Спасибо за помощь !!

1 Ответ

1 голос
/ 12 февраля 2012

Если вы хотите использовать RelativeLayouts, чтобы использовать лучшие возможности, нет необходимости использовать RelativeLayouts / LinearLayouts в других RelativeLayouts / LinearLayouts.

Примеры использования RelativeLayouts приведены в:

http://developer.android.com/resources/tutorials/views/hello-relativelayout.html

http://android -developers.blogspot.com / 2009/02 / android-layout-tricks-1.html

в крачкахиз того, что вы ищете, это то, что вы ищете:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/image"
        android:text="Name"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/description"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/name"
        android:layout_below="@+id/name"
        android:text="Description"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/date_created"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/name"
        android:layout_alignBottom="@+id/name"
        android:layout_alignParentRight="true"
        android:text="DateCreated"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/date_planned"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"            
        android:layout_alignBaseline="@+id/description"
        android:layout_alignBottom="@+id/description"
        android:layout_alignParentRight="true"
        android:text="DatePlanned"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>

Обратите внимание, что здесь есть жестко запрограммированные строки, чтобы вы могли видеть текст.Убедитесь, что вы удалили их и используете файл strings.xml.

...