<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/numberTV"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="@string/number" />
<EditText
android:id="@+id/numberET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/numberTV"
android:inputType="phone" />
<TextView
android:id="@+id/contentTV"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="@id/numberET"
android:text="@string/content" />
<EditText
android:id="@+id/contentET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/numberET"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/contentTV"
android:ems="10"
android:inputType="textMultiLine"
android:lines="3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/contentET"
android:onClick="onClick"
android:text="@string/send" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/numberTV"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="@string/number" />
<EditText
android:id="@+id/numberET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/numberTV"
android:inputType="phone" />
<TextView
android:id="@+id/contentTV"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="@id/numberET"
android:text="@string/content" />
<EditText
android:id="@+id/contentET"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/numberET"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/contentTV"
android:ems="10"
android:inputType="textMultiLine"
android:lines="3" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/contentET"
android:onClick="onClick"
android:text="@string/send" />
</RelativeLayout>
效果图:

本文深入探讨了Android应用开发中使用RelativeLayout布局管理器时,如何合理安排组件的位置与大小,通过实例展示了如何利用XML代码实现文本显示、输入框编辑和多行文本输入等功能,为开发者提供了一套实用的布局策略。

1265

被折叠的 条评论
为什么被折叠?



