首页 > 移动平台 > 详细

安卓界面控件屏幕居中Layout例子

时间:2014-10-29 12:25:58      阅读:385      评论:0      收藏:0      [点我收藏+]

经典的登录界面例子:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity = "center"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity = "center"
>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:textSize="16sp"
android:text="用户:"
android:layout_width="80dp"
android:layout_height="wrap_content" />

<EditText
android:layout_width="245dp"
android:layout_height="wrap_content"
android:imeActionId="@+id/login"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:layout_gravity="center_horizontal|bottom" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity = "center"
>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:textSize="16sp"
android:text="密码:"
android:layout_width="80dp"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/password"
android:layout_width="245dp"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:singleLine="true"
android:layout_gravity="center_horizontal|bottom" />
</LinearLayout>

<Space
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="center_horizontal" />

<Button android:text="登录"
android:layout_width="120dp"
android:layout_height="wrap_content" />

</LinearLayout>

 

安卓界面控件屏幕居中Layout例子

原文:http://www.cnblogs.com/legahero/p/Layout.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!