tags:

views:

109

answers:

3

Hi,

I am trying to accomplish a view like this: left side = live camera preview, right side = a column of 4 images. But all that I managed with the following xml was a fullscreen live camera preview. Android 1.5 emulator.

Thanks

<?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>
A: 

Checkout the below one... It works as per your requirement.....

Replace the Linear Layout with yours....

<?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>
Vishwanath
Thanks for dropping thie layout. Still does not work as it should.
kellogs
Your layout "proto.wiinkme.SurfaceViewEx" is Linear or Relative....?
Vishwanath
It is not a layout, it is a class derived from SurfaceView
kellogs
+1  A: 

Vishwanath,

I have adjusted your layout like this

<?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>

And had some rather strange effects.

kellogs
A: 

This is how I have worked around it, but it is still wrong, as it can be seen, I have hardcoded the dimensions of my elements in 'dips'. Probably fine for pre 1.6 but in post 1.6 incuding 1.6 version of Android this layout will break for other screens than 320 x 480 3.2 inches.

<?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>
kellogs