问题描述
我正在尝试使用可折叠的工具栏。在Appbar
中,我有一个ConstraintLayout
,其中有textView
和Cardview
。在android studio中,一切正常,但是在移动设备上,我看不到自己的textView
。
这是android studio screen,这是mobile screen。
,这是具有CoordinatorLayout
作为父元素,具有工具栏的CollapsingToolbarLayout
和ConstraintLayout
的布局。在ConstraintLayout
中,我有一个textView
和三个CardView
。当我取消对CardViews的注释时,它们还可以,但是我的textView
没有显示。通过使用开发人员工具,我可以看到textView
的边界,但是textView
的文本没有显示。我将textColor
甚至ConstraintLayout
更改为LinearLayout
,但是什么都没有改变。
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:fitsSystemWindows="true"
android:layoutDirection="rtl"
tools:context=".activity.DetailsActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout_activity_details"
style="@style/MyCustomToolbarStyle"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_app_bar_height"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsingToolbar_activity_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@id/materialToolbar_activity_details">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout_profile"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax">
<TextView
android:id="@+id/appCompatTextView"
android:textColor="@android:color/holo_red_light"
android:visibility="visible"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:onClick="showToast"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/horizontal_guideline"
tools:text="@string/app_name" />
<!-- <androidx.cardview.widget.CardView
android:id="@+id/cardView_profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
app:cardCornerRadius="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/horizontal_guideline">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/square" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="70dp"
android:layout_height="70dp"
app:cardCornerRadius="35dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/cardView_profile_image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/horizontal_guideline">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/square" />
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="70dp"
android:layout_height="70dp"
app:cardCornerRadius="35dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/cardView_profile_image"
app:layout_constraintTop_toTopOf="@+id/horizontal_guideline">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/square" />
</androidx.cardview.widget.CardView>-->
<androidx.constraintlayout.widget.Guideline
android:id="@+id/horizontal_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="56dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/materialToolbar_activity_details"
style="@style/MyCustomToolbarStyle"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<androidx.appcompat.widget.AppCompatimageView
android:id="@+id/imageView_backButton_detail_activity"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_action_filter" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/textView_back_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/imageView_backButton_detail_activity"
android:text="بازگشت"
android:textColor="@android:color/white" />
</RelativeLayout>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/appBarLayout_activity_details"
app:layout_anchorGravity="center"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.core.widget.nestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textView_temp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/large_text" />
</androidx.core.widget.nestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)