android - 如何在线性布局中的另一个文本下方制作文本?
问题描述
1.我正在创建一个登录页面,我想在“注册”文本下方的“忘记密码”文本我该怎么办?我还想在“忘记密码”文本下方添加一个进程栏
2.这是我的登录布局的XML代码:我试图将进程栏和忘记密码文本放在衬垫布局中,但这两项不会显示在登录页面中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="@drawable/bg"
tools:context=".LoginPage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="-27dp"
android:background="@drawable/bgcard"
android:orientation="vertical"
android:padding="40dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="@font/quicksand_bold"
android:text="Welcome Back!"
android:textColor="#0F0F0F"
android:textSize="34dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="12dp"
android:fontFamily="@font/quicksand_bold"
android:text="This here add detail about article."
android:textColor="#3A3A3A"
android:textSize="18dp" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputUsername"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="42dp"
android:background="@drawable/bg_editext"
android:hint="User Name"
android:paddingLeft="18dp"
android:singleLine="true" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputPassword"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="14dp"
android:background="@drawable/bg_editext"
android:hint="Password"
android:paddingLeft="18dp"
android:singleLine="true" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:background="@drawable/bg_btn"
android:singleLine="true"
android:text="Login"
android:textColor="#FFFFFF"
android:textSize="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginBottom="28dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/quicksand_book"
android:text="you don't have account already?"
android:textColor="#363636"
android:textSize="16dp" />
<TextView
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:fontFamily="@font/quicksand_book"
android:text="Sign Up"
android:textColor="#1F1F1F"
android:textSize="16dp" />
<TextView
android:id="@+id/resetText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:gravity="center"
android:text="Forgot Password"
/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_marginLeft="120dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
解决方案
看起来您已将忘记的密码和进度条放在水平的内部线性布局内。这使它们最终出现在屏幕之外。
将它们移动到外部线性布局应该可以解决您的问题。
`
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="-27dp"
android:background="@drawable/bgcard"
android:orientation="vertical"
android:padding="40dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="@font/quicksand_bold"
android:text="Welcome Back!"
android:textColor="#0F0F0F"
android:textSize="34dp" />
<!-- Your other views here -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginBottom="28dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/quicksand_book"
android:text="you don't have account already?"
android:textColor="#363636"
android:textSize="16dp" />
<TextView
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:fontFamily="@font/quicksand_book"
android:text="Sign Up"
android:textColor="#1F1F1F"
android:textSize="16dp" />
</LinearLayout>
<TextView
android:id="@+id/resetText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:gravity="center"
android:text="Forgot Password" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_marginLeft="120dp"
android:layout_height="wrap_content" />
</LinearLayout>
`
推荐阅读
- python - 从列表 Python 列表中的特定点循环
- ansible - ansible vars_files 与 include_vars
- google-sheets - 查找两个日期之间的天数?
- google-maps - 为什么不同的 Google 服务具有相同的 IP 地址?
- api - 通过 Cloudflare API 转发 URL
- python - Python 错误 u'标签 [-1] 不在 [index] 中'
- php - 我的 Wordpress 网站上的 3 个不同时间
- mendeley - Mendeley Web Importer 中的奇怪结果
- c# - 将标签传递给不更新label.text的方法?
- python - 如何使用 Discord.py Rewrite (1.0.0) 版本播放音乐