2010-04-27 4 views
0

J'essaye d'accomplir une vue comme ceci: côté gauche = aperçu de caméra en direct, côté droit = ​​une colonne de 4 images. Mais tout ce que j'ai réussi avec le xml suivant était un aperçu en direct de la caméra en plein écran. Émulateur Android 1.5.Quel est le problème avec cette mise en page? Android

Merci

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

Répondre

0

Commander le dessous d'un ... Il fonctionne selon vos besoins .....

Remplacer la disposition linéaire avec le vôtre ....

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

Merci d'avoir omis la mise en page. Ça ne marche toujours pas comme il se doit. – kellogs

+0

Votre disposition "proto.wiinkme.SurfaceViewEx" est linéaire ou relatif ....? – Vishwanath

+0

Ce n'est pas une mise en page, c'est une classe dérivée de SurfaceView – kellogs

1

Vishwanath,

J'ai ajusté votre disposition comme ceci

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

Et avait des effets plutôt étranges.

0

C'est ainsi que j'ai travaillé autour de ça, mais c'est encore faux, comme on peut le voir, j'ai codé en dur les dimensions de mes éléments en 'trempettes'. Probablement bien pour le pré 1.6 mais en post 1.6 incluant la version 1.6 d'Android cette mise en page va se casser pour d'autres écrans que 320 x 480 3,2 pouces.

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