我在LinearLayout中添加了一个ScrollView,它在运行应用程序时是隐藏的。这是XML。
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/unit_128">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/login_title"
android:layout_marginBottom="@dimen/_16sdp"
android:gravity="center">
<ImageView
android:id="@+id/learn_more_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_paper" />
<TextView
android:id="@+id/learn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/_8sdp"
android:fontFamily="@font/work_sans"
android:text="@string/fsa_regulated_learn_more"
android:textColor="@color/white" />
</LinearLayout>
<TextView
android:id="@+id/login_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/unit_16"
android:layout_marginTop="@dimen/unit_32"
android:layout_marginEnd="@dimen/unit_16"
android:fontFamily="@font/work_sans"
android:gravity="center"
android:text="@string/sign_in_to_get_started"
android:textColor="@color/white"
android:textSize="@dimen/_14sp" />
<EditText
android:id="@+id/email_edt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_title"
android:layout_marginStart="@dimen/unit_16"
android:layout_marginTop="@dimen/unit_24"
android:layout_marginEnd="@dimen/unit_16"
android:background="@drawable/border_btn"
android:drawableStart="@drawable/ic_icon_user"
android:drawablePadding="@dimen/_8sdp"
android:fontFamily="@font/work_sans_medium"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:padding="@dimen/unit_12"
android:singleLine="true"
android:text="@={viewModel.emailObservable}"
android:textColor="@color/white"
android:textColorHint="#707070"
android:textSize="@dimen/_15sp"
app:error="@{viewModel.errEmailObservable}" />
<EditText
android:id="@+id/password_edt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/email_edt"
android:layout_marginStart="@dimen/unit_16"
android:layout_marginTop="@dimen/unit_16"
android:layout_marginEnd="@dimen/unit_16"
android:background="@drawable/border_btn"
android:drawableStart="@drawable/ic_password"
android:drawablePadding="@dimen/_8sdp"
android:fontFamily="@font/work_sans"
android:hint="@string/password"
android:inputType="textPassword"
android:padding="@dimen/unit_12"
android:singleLine="true"
android:text="@={viewModel.passwordObservable}"
android:textColor="@color/white"
android:textColorHint="#707070"
android:textSize="@dimen/_15sp"
app:error="@{viewModel.errPasswordObservable}" />
<TextView
android:id="@+id/error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password_edt"
android:layout_marginStart="@dimen/unit_16"
android:layout_marginTop="@dimen/unit_8"
android:layout_marginEnd="@dimen/unit_16"
android:fontFamily="@font/work_sans"
android:gravity="start"
android:paddingStart="@dimen/_8sdp"
android:paddingEnd="@dimen/_8sdp"
android:text="@={viewModel.generalErrorObservable}"
android:textColor="@color/red"
android:textSize="@dimen/_12sp"
android:visibility='@{viewModel.generalErrorObservable.empty? View.GONE : View.VISIBLE}' />
<Button
android:id="@+id/submit_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/error"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/unit_16"
android:layout_marginTop="@dimen/unit_16"
android:layout_marginEnd="@dimen/unit_16"
android:background="@drawable/rounder_btn"
android:backgroundTint="@{viewModel.lockedAccountErrorObservable ? @color/selected_bottom_color : @color/green}"
android:enabled="@{!viewModel.lockedAccountErrorObservable}"
android:onClick="@{() -> viewModel.submitLoginPress()}"
android:padding="@dimen/unit_8"
android:text="@string/login"
android:textColor="@color/white"
android:textSize="@dimen/_18sp" />
<TextView
android:id="@+id/forgot_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/submit_btn"
android:layout_marginStart="@dimen/unit_16"
android:layout_marginTop="@dimen/unit_16"
android:layout_marginEnd="@dimen/unit_16"
android:layout_marginBottom="@dimen/unit_64"
android:fontFamily="@font/work_sans"
android:gravity="center"
android:onClick="@{() -> viewModel.forgetPasswordPress()}"
android:text="@string/forgot_password"
android:textColor="@color/white"
android:textSize="@dimen/_14sp" />
</RelativeLayout>
</ScrollView>
</layout>
为什么LinearLayout是隐藏的,如何在这里显示它?谢谢
发布于 2022-02-17 19:22:23
我试过你的密码,看上去不错。当我像下面这样调用片段时,它就起作用了。
<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"
tools:context=".FirstFragment">
<include layout="@layout/yourLayout"/>
</androidx.constraintlayout.widget.ConstraintLayout>
也许你在<包含布局上做错了。因为,您当前的XML布局似乎很好。
https://stackoverflow.com/questions/71162969
复制相似问题