Что не так с этим макетом? Android - PullRequest
0 голосов
/ 27 апреля 2010

Я пытаюсь создать вид, подобный следующему: левая сторона = предварительный просмотр с камеры, правая сторона = столбец из 4 изображений. Но все, что мне удалось с помощью следующего xml, - это полноэкранный предварительный просмотр с камеры. Эмулятор Android 1.5.

Спасибо

<?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="fill_parent">

    <proto.wiinkme.SurfaceViewEx 
        android:id="@+id/preview" 
        android:layout_height="fill_parent" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_weight="3"/>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@+id/preview"
        android:layout_alignParentRight="true"
        android:layout_weight="1">

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/mother_earth"
            android:src="@drawable/mother_earth_show" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/meadow"
            android:src="@drawable/meadow_show" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/trap"
            android:src="@drawable/trap_show" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/whistle"
            android:src="@drawable/whistle_show" />


    </LinearLayout>

</RelativeLayout>

Ответы [ 3 ]

1 голос
/ 27 апреля 2010

Вишванат,

Я настроил ваш макет следующим образом

<?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="fill_parent">

    <LinearLayout
        android:layout_height="fill_parent" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_weight="3">

        <proto.wiinkme.SurfaceViewEx 
            android:id="@+id/preview" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>

    </LinearLayout>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@+id/preview"
        android:layout_alignParentRight="true"
        android:layout_weight="2">

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/mother_earth"
            android:src="@drawable/mother_earth_show" />

        <ImageView
            android:layout_below = "@+id/mother_earth"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/meadow"
            android:src="@drawable/meadow_show" />

        <ImageView
            android:layout_below = "@+id/meadow"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/trap"
            android:src="@drawable/trap_show" />

        <ImageView
            android:layout_below = "@+id/trap"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/whistle"
            android:src="@drawable/whistle_show" />

        <Button
            android:layout_below = "@+id/whistle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/reset"
            android:text="Reset" />

        <Button
            android:layout_below = "@+id/reset"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/save"
            android:text="Save" />


    </RelativeLayout>

</RelativeLayout>

И имел довольно странные эффекты.

0 голосов
/ 27 апреля 2010

Вот как я обошел это, но это все же неправильно, как видно, я жестко закодировал размеры своих элементов в «провалах». Вероятно, это хорошо для предварительной версии 1.6, но в версии 1.6, включая версию Android 1.6, эта раскладка будет нарушена для других экранов, кроме 320 x 480 3,2 дюйма.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <proto.wiinkme.SurfaceViewEx 
        android:id="@+id/preview" 
        android:layout_height="fill_parent" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_weight="3"/>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@+id/preview"
        android:layout_alignParentRight="true"
        android:layout_weight="1">

        <ImageView
            android:layout_width="100dip"
            android:layout_height="80dip"
            android:id="@+id/mother_earth"
            android:src="@drawable/mother_earth_show" />

        <ImageView
            android:layout_width="100dip"
            android:layout_height="80dip"
            android:id="@+id/meadow"
            android:src="@drawable/meadow_show" />

        <ImageView
            android:layout_width="100dip"
            android:layout_height="80dip"
            android:id="@+id/trap"
            android:src="@drawable/trap_show" />

        <ImageView
            android:layout_width="100dip"
            android:layout_height="80dip"
            android:id="@+id/whistle"
            android:src="@drawable/whistle_show" />

        <Button
            android:layout_marginTop="4dip"
            android:layout_width="78dip"
            android:layout_height="80dip"
            android:id="@+id/reset"
            android:text="Reset" />

        <Button
            android:layout_width="78dip"
            android:layout_height="80dip"
            android:id="@+id/save"
            android:text="Save" />


    </LinearLayout>

</LinearLayout>
0 голосов
/ 27 апреля 2010

Оформить заказ ниже одного ... Он работает в соответствии с вашими требованиями .....

Замените линейный макет своим ....

<?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="fill_parent">

    <LinearLayout
        android:id="@+id/preview" 
        android:layout_height="fill_parent" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_weight="3">
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:src="@drawable/icon" />
    </LinearLayout>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@+id/preview"
        android:layout_alignParentRight="true"
        android:layout_weight="2">

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/mother_earth"
            android:src="@drawable/icon" />

        <ImageView
            android:layout_below = "@+id/mother_earth"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/meadow"
            android:src="@drawable/icon" />

        <ImageView
            android:layout_below = "@+id/meadow"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/trap"
            android:src="@drawable/icon" />

        <ImageView
            android:layout_below = "@+id/trap"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/whistle"
            android:src="@drawable/icon" />


    </RelativeLayout>

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