android登陆页面
时间: 2023-08-10 15:24:04 浏览: 43
Android 登录页面通常由两个 EditText(用于输入用户名和密码)、一个登录按钮和一个注册链接组成。以下是一个简单的 Android 登录页面示例:
```
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/editText_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="用户名" />
<EditText
android:id="@+id/editText_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="密码"
android:inputType="textPassword" />
<Button
android:id="@+id/button_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录" />
<TextView
android:id="@+id/textView_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册新账号"
android:textColor="@color/colorAccent"
android:gravity="center"
android:textStyle="bold" />
</LinearLayout>
```
在 Java 代码中,您可以使用 findViewById 方法获取 EditText 和 Button 的实例。然后,您可以添加一个 OnClickListener 到登录按钮上,以便在用户单击该按钮时执行登录操作。您还可以添加一个 OnClickListener 到注册链接上,以便在用户单击该链接时导航到注册页面。