Не удается установить фон в макете BottomSheetBehavior? - PullRequest
0 голосов
/ 10 июля 2020

Я использую материал BottomSheetBehavior

Это мой макет

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/parentLayoutSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:behavior_hideable="false"
app:behavior_peekHeight="0dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">



<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/waysToWatchOptions"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="20dp"
    android:layout_marginEnd="20dp"
    android:layout_marginBottom="20dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:text="@string/ways_to_watch"
        android:textAllCaps="true"
        android:textColor="@android:color/white"
        android:textSize="18sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/description"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:text="@string/ways_to_watch_msg"
        android:textColor="@android:color/white"
        android:textSize="14sp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/title" />
    </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>

Это мой класс, с помощью которого я устанавливаю цвет фона и текста, но они не отображаются так, как они следует

class WaysToWatchBottom(val appCMSPresenter: AppCMSPresenter, val videoContentDatum: ContentDatum) {
private var sheetBehavior: BottomSheetBehavior<*>

@BindView(R.id.parentLayout)
lateinit var parentLayout: ConstraintLayout

@BindView(R.id.title)
lateinit var title: AppCompatTextView

@BindView(R.id.description)
lateinit var description: AppCompatTextView

init {
    val li = LayoutInflater.from(appCMSPresenter.currentContext)
    val layout = li.inflate(R.layout.fragment_ways_to_bottom, null, false)
    ButterKnife.bind(this, layout)

    val sheetLayout: ConstraintLayout = appCMSPresenter.currentActivity.findViewById(R.id.parentLayoutSheet)

    sheetBehavior = BottomSheetBehavior.from(sheetLayout)

    if (sheetBehavior.state != BottomSheetBehavior.STATE_EXPANDED) {
        sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED)
    } else {
        sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED)
    }
    setViewStyles()
    
}
private fun setViewStyles() {
    parentLayout.setBackgroundColor(appCMSPresenter.generalBackgroundColor)
    title.setTextColor(appCMSPresenter.generalTextColor)
    description.setTextColor(appCMSPresenter.generalTextColor)}


}

В чем проблема?

...