Transferred from: http://blog.csdn.net/fansongy/article/details/6817968
Review the layout with XML and write an empty login interface. The XML comment I wrote at the back of the line. Program Run diagram:
The main function is not changed, not posted. The background image is named: Background.jpg. Let's see Main.xml.
[HTML]View Plaincopyprint?
- <? XML version= "1.0" encoding="Utf-8"?>
- <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/background"//Set background
- >
- <linearlayout android:id="@+id/empty"//layout for placeholder
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight ="1"></linearlayout>//Set Percentage of total weight
- <relativelayout android:id="@+id/relativelayout"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="2"
- android:padding="10px">//Set inner spacing
- /* The color and opacity (alpha) values are indicated in hexadecimal notation. The range of values for any one color is 0 to 255 (00 to FF). For alpha,00, full transparency is expressed, and FF is completely opaque. The expression order is "Aabbggrr", where "aa=Alpha" (00 to FF); "bb=Blue" (00 to FF); "gg=Green" (00 to FF);rr= Red "(00 to FF). For example, if you want to apply a blue 50% opacity to an overlay, you should specify the following values: 7fff0000 */
- <TextView
- android:id="@+id/user"
- android:text="user name:"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textcolor="#ffffffff" />
- <EditText android:id="@+id/username"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/user"//under the control with ID user
- android:background="#88ffffff"/>//Set opaque
- <TextView
- android:id="@+id/key"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Password:"
- android:layout_below="@id/username"
- android:textcolor="#ffffffff" />
- <EditText android:id="@+id/keyword"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/key"
- android:background="#88ffffff"
- android:password="true"/>
- <checkbox android:id="@+id/remember"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="Remember password"
- android:layout_below="@id/keyword"
- android:layout_alignleft="@id/keyword"
- android:layout_marginleft="15px"/>//Outside spacing
- <checkbox android:id="@+id/autoin"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:text="Automatic login"
- android:layout_below="@id/keyword"
- android:layout_alignright="@id/keyword"//right-aligned with the control with ID keyword
- android:layout_marginright="15px"/>
- <button android:id="@+id/enter"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:gravity="center_horizontal"//Internal text position
- android:text="Login"
- android:layout_below="@id/autoin"
- android:layout_margin="10px"/>
- </relativelayout>
- </linearlayout>
This blog from the Asura Road, reproduced please indicate the source: http://blog.csdn.net/fansongy/article/details/6817968
Android Basics review--relativelayout layout properties, background, translucency settings (XML settings)