Android - User Interface

来源:互联网 发布:java环境配置 编辑:程序博客网 时间:2024/05/16 01:32
You can declare a layout in two ways:
  • Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.

  • Instantiate layout elements at runtime. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically.
》RelativeLayout
 By default, all child views are drawn at the top-left of the layout, so you must define the position of each view using the various layout properties available from RelativeLayout.LayoutParams.
<?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"    android:paddingLeft="16dp"    android:paddingRight="16dp" >    <EditText        android:id="@+id/name"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:hint="@string/reminder" />    <Spinner        android:id="@+id/dates"        android:layout_width="0dp"        android:layout_height="wrap_content"        android:layout_below="@id/name"        android:layout_alignParentLeft="true"        android:layout_toLeftOf="@+id/times" />    <Spinner        android:id="@id/times"        android:layout_width="96dp"        android:layout_height="wrap_content"        android:layout_below="@id/name"        android:layout_alignParentRight="true" />    <Button        android:layout_width="96dp"        android:layout_height="wrap_content"        android:layout_below="@id/times"        android:layout_alignParentRight="true"        android:text="@string/done" /></RelativeLayout>

0 0