2011-10-28 12 views
1

は、私は私のアプリのレイアウトをデザインしたい私はRelativeLayoutプロパティを使用しますか?画像に下記のように

layout to be designed

が、IMは相対的なレイアウトに適用する性質があり、私のXMLコードの下に右のように行くされていないことである問題を取得イムcenterInParentプロパティを持つ水平ルーラーイメージとcenterInParentのプロパティを持つverticle rulerイメージです。両方のルーラーが正確な位置に来るようにしますが、子供を水平ルーラーまたは子toLeftOf verticleルーラーの上に置くと、グラフィカルビューとして表示されませんxmlファイルの中には、centerInParentを適用することによって、両方のルーラーが中心に来るが、それらの参照がエッジに残っている理由が示されます。その理由は、layout_aboveまたはlayoutチャイルズは、レイアウトの外に出_toLeftOf

私のXMLコード

<?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" 
      android:background="#FFFFFF" 
      android:orientation="vertical"> 

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="@drawable/title" 
     > 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/icon_img" 
      android:layout_alignParentLeft="true" 
      android:layout_marginLeft="10dip" 
      android:layout_marginTop="2.5dip" 
      android:src="@drawable/smicon" 
     /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="15dip" 
      android:layout_toRightOf="@id/icon_img" 
      android:layout_marginTop="3dip" 
      android:text="Welcome To JEM" 
      android:textStyle="bold" 
      android:id="@+id/wcm_id" 
      android:textSize="18dip" 
      android:textColor="#FFFFFF" 
     /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@id/wcm_id" 
      android:layout_alignParentRight="true" 
      android:layout_marginRight="5dip" 
      android:text="APPS BY SAM" 
      android:id="@+id/app_by" 
      android:textSize="16dip" 
      android:textColor="#FFFFFF" 
     /> 
    </RelativeLayout> 

    <!-- This relative layout which is showing the main cross and icon around it --> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="20dip" 
    > 


    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/center_hr" 
      android:layout_centerInParent="true" 
      android:src="@drawable/horizontal" 
    /> 

    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/center_vr" 
      android:layout_centerInParent="true" 
      android:src="@drawable/verticle" 
    /> 

    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@id/center_hr" 
      android:layout_toLeftOf="@id/center_vr" 
      android:id="@+id/getuser" 
      android:src="@drawable/adduser" 
    /> 

<ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@id/center_hr" 
      android:layout_toRightOf="@id/center_vr" 
      android:id="@+id/set" 
      android:src="@drawable/set" 
/> 

<ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/center_hr" 
      android:layout_toLeftOf="@id/center_vr" 
      android:id="@+id/get" 
      android:src="@drawable/get" 
/> 

<ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/center_hr" 
      android:layout_toRightOf="@id/center_vr" 
      android:id="@+id/ico" 
      android:src="@drawable/icon" 
/> 

</RelativeLayout> 

</LinearLayout> 

ので、みんながイメージ

に示したように、私はその下、右、上、LEFするために、このメインクロスやアイコンをachiveことができる方法を教えてください

答えて

1

これを試してみてください。..

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center_vertical|center_horizontal"> 
<ImageView 
android:id="@+id/imageView1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"/> 
<ImageView 
android:id="@+id/vertical_ruler" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_toRightOf="@id/imageView1"/> 

<ImageView 
android:id="@+id/imageView2" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_toRightOf="@id/vertical_ruler" 
/> 
<ImageView 
android:id="@+id/horizontal_ruler" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_below="@id/imageView1"/> 
<ImageView 
android:id="@+id/imageView3" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_below="@id/horizontal_ruler"/> 
<ImageView 
android:id="@+id/imageView4" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_toRightOf="@id/vertical_ruler" 
android:layout_below="@id/horizontal_ruler" 
/> 

、それはあなたのために役立つかもしれない。..

+0

+1いいです、他の人に役立ちます。 –

0

RelativeLayoutに埋め込まれたTableLayoutを使用できます。 RelativeLayoutを使用すると、TableLayoutを画面中央に配置することができ、TableLayoutに画像/ボタンを追加して、TableLayoutに必要な行と列の数を指定できます。

関連する問題