0. 设计的几个布局的效果如下:
1.针对线性布局设计的登录界面
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户登录"
android:textSize="40sp"
android:textColor="#000000"
android:textStyle="normal"
android:layout_marginTop="100dp"
android:layout_gravity="center"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名:"
android:textSize="20sp"
android:textColor="#000000"/>
<EditText
android:id="@+id/edit_inputname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入用户名"
android:textSize="20sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码:"
android:textSize="20sp"
android:textColor="#000000"/>
<EditText
android:id="@+id/edit_inputpwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码"
android:inputType="textPassword"
android:textSize="20sp"
/>
</LinearLayout>
<CheckBox
android:id="@+id/check_remeber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="记住密码"
android:textStyle="normal"
android:layout_gravity="right"
android:layout_margin="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="center">
<Button
android:id="@+id/button_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:textSize="30sp"
android:textColor="#050505"
android:layout_weight="1"/>
<Button
android:id="@+id/button_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消"
android:textSize="30sp"
android:textColor="#050505"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
2、针对相对布局设计的简单游戏界面
<?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="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
tools:context=".MainActivity">
<ImageView
android:id="@+id/Game"
android:layout_width="wrap_content"
android:layout_height="240dp"
android:src="@drawable/game"
android:layout_marginBottom="30dp"
/>
<Button
android:id="@+id/button_up"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_below="@+id/Game"
android:layout_alignLeft="@+id/Blank"
android:background="@drawable/up"/>
<ImageView
android:id="@+id/Blank"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="60dp"
android:layout_below="@+id/button_up"
android:src="@drawable/blank"
/>
<Button
android:id="@+id/button_down"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_below="@+id/Blank"
android:layout_alignLeft="@+id/Blank"
android:background="@drawable/down"/>
<Button
android:id="@+id/button_left"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="60dp"
android:layout_toRightOf="@+id/Blank"
android:layout_alignTop="@+id/Blank"
android:layout_below="@+id/Game"
android:background="@drawable/left"/>
<ImageView
android:id="@+id/Blank1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_toRightOf="@+id/button_left"
android:layout_alignTop="@+id/button_left"
android:src="@drawable/blank"
/>
<Button
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_toRightOf="@+id/Blank1"
android:layout_alignTop="@+id/Blank1"
android:background="@drawable/right"/>
<Button
android:id="@+id/button_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始游戏"
android:layout_below="@+id/button_down"
android:layout_alignLeft="@+id/button_down"
android:layout_marginTop="30dp"
android:textSize="30sp"
android:textColor="#050505"
android:layout_weight="1"/>
<Button
android:id="@+id/button_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="退出游戏"
android:layout_below="@+id/Blank1"
android:layout_alignTop="@+id/button_start"
android:layout_toRightOf="@+id/button_start"
android:textSize="30sp"
android:textColor="#050505"
android:layout_weight="1"/>
</RelativeLayout>
3. 帧布局、线性布局设计后台界面
)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/background">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/icon"
android:layout_gravity="center"
android:layout_marginTop="-20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="久醉"
android:textSize="30sp"
android:textColor="#ffffff"
android:layout_gravity="center"
android:layout_marginTop="40dp"/>
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="个人中心"
android:textSize="30sp"
android:textStyle="normal"
android:layout_gravity="center"
android:layout_marginBottom="20dp"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#E91A1A"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设置"
android:textSize="25sp"
android:padding="10dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#C5C2C2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="修改密码"
android:textSize="25sp"
android:padding="10dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#C5C2C2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="作品详情"
android:textSize="25sp"
android:padding="10dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#C5C2C2"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注销"
android:textSize="25sp"
android:padding="10dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#C5C2C2"
/>
</LinearLayout>