1. 设计登录页面

比较简单,重要的点就一个,有一个记住密码的按钮。
代码实现
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.13" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.789" />
<EditText
android:id="@+id/editTextTextPersonName"
android:layou

这篇博客介绍了如何在Android中设计一个简单的登录页面,包括用户名和密码输入框以及记住密码功能。登录按钮点击时,使用SharedPreferences保存用户输入的登录信息。此外,还展示了如何读取保存的数据并显示在文本视图上。最后,提供了查看保存数据的文件路径。

7959

被折叠的 条评论
为什么被折叠?



