未为TextView显示高程。下面是一个布局:
<?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="wrap_content"
tools:context=".presentation.TrainingListFragment">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/schedule_label"
style="@style/Widget.AppCompat.TextView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/background_selector"
android:elevation="15dp"
android:fontFamily="@font/inter_medium"
android:gravity="center_horizontal|center_vertical"
android:outlineProvider="none"
android:text="@string/schedule"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_list_of_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="65dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/schedule_label"
tools:listitem="@layout/list_of_days_item" />
</androidx.constraintlayout.widget.ConstraintLayout>
这是TextView的背景选择器:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/bottom_bar_background" />
<corners android:radius="5dp" />
</shape>
我尝试了所有的建议从Elevation on Android Lollipop not working和从这里Android "elevation" not showing a shadow
我想不出原因是什么。你的建议?!
1条答案
按热度按时间hi3rlvi21#
我解决了这个问题,当我设置背景形状选择器与颜色不同的白色。