我应该用什么RelativeLayout的属性? [英] what RelativeLayout properties should i use?
问题描述
我想设计在图像下面所示为我的应用程序布局
i want to design a layout for my app as shown below in image
但即时得到问题,就是性质即时通讯申请相对布局不正确的,如下面我的XML code去那里是具有centerInParent属性,并且还通过做有centerInParent的财产verticle标尺图像水平标尺图像这两个标尺来准确的地方,但是当我把一个孩子的水平标尺或toLeftOf他们不显示为XML文件的图形视图verticle统治者孩子上面显示的原因,虽然通过应用centerInParent两个统治者来到中心,但他们参考为什么使用layout_above保持在边缘的多数民众赞成或layout_toLeftOf孩子的去布局之外
but im getting problem which is that the properties im applying for relative layout are not going right as in below my xml code there is horizontal ruler image having centerInParent property and a verticle ruler image also having property of centerInParent by doing this the both rulers come to accurate place but when i put a child above the horizontal ruler or a child toLeftOf verticle ruler they dont appear as the graphical view of xml file shows the reason that although by applying centerInParent the both rulers come to center but their reference remains at edges thats why by using layout_above or layout_toLeftOf the childs go outside of layout
我的XML code
My xml code
<?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>
所以,请你们告诉我,我怎么能achive这个主跨和图标LEF,右和上,下它,如图像
so guys please tell me how can i achive this main cross and icon to lef,right and above,below it as shown in image
推荐答案
试试这个..
<?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"
/>
可能是它为您有所帮助。
May be it helpful for you..
这篇关于我应该用什么RelativeLayout的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!