<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <Button android:id="@+id/button1" android:layout_centerInParent="true" android:layout_width="80dp" android:layout_height="80dp" android:background="#000000" android:text=""/> <Button android:id="@+id/button2" android:layout_width="80dp" android:layout_height="80dp" android:background="#00FF00" android:layout_toLeftOf="@+id/button1" android:layout_centerVertical="true" android:text=""/> <Button android:id="@+id/button3" android:layout_width="80dp" android:layout_height="80dp" android:background="#ff0000" android:layout_above="@+id/button1" android:layout_centerHorizontal="true" android:text=""/> <Button android:id="@+id/button4" android:layout_width="80dp" android:layout_height="80dp" android:background="#ff00ff" android:layout_above="@+id/button2" android:layout_toLeftOf="@+id/button3" android:layout_centerHorizontal="true" android:text=""/> <Button android:id="@+id/button5" android:layout_width="80dp" android:layout_height="80dp" android:background="#00fff0" android:layout_below="@+id/button1" android:layout_centerHorizontal="true" android:text=""/> <Button android:id="@+id/button6" android:layout_width="80dp" android:layout_height="80dp" android:background="#ffff00" android:layout_below="@+id/button2" android:layout_toLeftOf="@+id/button5" android:layout_centerVertical="true" android:text=""/> <Button android:id="@+id/button7" android:layout_width="80dp" android:layout_height="80dp" android:background="#8f00" android:layout_toRightOf="@+id/button1" android:layout_centerVertical="true" android:text=""/> <Button android:id="@+id/button8" android:layout_width="80dp" android:layout_height="80dp" android:background="#0000FF" android:layout_above="@+id/button7" android:layout_toRightOf="@+id/button3" android:layout_centerHorizontal="true" android:text=""/> <Button android:id="@+id/button9" android:layout_width="80dp" android:layout_height="80dp" android:background="#8800ff00" android:layout_below="@+id/button7" android:layout_toRightOf="@+id/button5" android:layout_centerHorizontal="true" android:text="" /> </RelativeLayout>
<?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:background="#E6E6E6" android:orientation="vertical"> <ImageView android:id="@+id/iv" android:layout_width="70dp" android:layout_height="70dp" android:layout_centerHorizontal="true" android:layout_marginTop="40dp" android:src="@drawable/aa"></ImageView> <LinearLayout android:id="@+id/l1_number" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/iv" android:layout_centerVertical="true" android:layout_marginBottom="5dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="15dp" android:background="#FFFFFF"> <TextView android:id="@+id/tv_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="账号:" android:textColor="#000" android:textSize="20sp"/> <EditText android:id="@+id/et_number" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:background="@null" android:padding="10dp"/> </LinearLayout> <LinearLayout android:id="@+id/l1_password" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/l1_number" android:layout_centerVertical="true" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="#FFFFFF"> <TextView android:id="@+id/tv_password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="密码:" android:textColor="#000" android:textSize="20sp"/> <EditText android:id="@+id/et_password" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_toRightOf="@id/tv_password" android:background="@null" android:inputType="textPassword" android:padding="10dp"/> </LinearLayout> <Button android:id="@+id/btn_login" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/l1_password" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="50dp" android:background="#3c8dc4" android:text="登录" android:textColor="#FFFFFF" android:textSize="20sp"/> </RelativeLayout> package com.example.text; import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }