我想为所有布局创建一个xml文件,以便在设备中保持相同的比例和位置。适用于所有屏幕尺寸的Android xml布局
这里,是我的布局设计,我想创建:
这里是我的布局xml文件: 当我使用这个XML,在一些屏幕的圆形按钮不一样大小我上的图像和文本视图中的“图像”视图(0.0公里)中,“圆形按钮”是不是在中间位置:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="50dp"
android:layout_alignParentTop="true"
android:src="@drawable/firstscreenimage" />
</RelativeLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_marginBottom="92dp"
android:gravity="right"
android:text="0.0km"
android:textSize="130dp" />
<Button
android:id="@+id/button1"
android:layout_width="400dp"
android:layout_height="400dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="150dp"
android:background="@drawable/animation0" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:textSize="35dp"
android:layout_alignBottom="@+id/button1"
android:layout_centerHorizontal="true"
android:text="Start" />
<EditText
android:id="@+id/campa"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="23dp"
android:ems="10" >
<requestFocus />
</EditText>
</RelativeLayout>
这是错误的布局:
请帮助我,对不起我的英语不好。谢谢....
你需要你的文本视图,使其在屏幕的中间或者是右对齐,如第一张截图? –
@ ravindra.kamble被右对齐。谢谢 –