ScrollView не показывает верхнюю часть во фрагменте диалога - PullRequest
0 голосов
/ 14 мая 2019

У меня есть ScrollView внутри CardView во фрагменте диалога.Если текст большой, верхняя часть будет скрыта .XML:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                         xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
                                         android:layout_height="wrap_content"
                                         >

<android.support.v7.widget.CardView
        style="@style/CardViewStyle"
        android:layout_width="match_parent"

        android:id="@+id/explCard"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp" app:layout_constraintBottom_toTopOf="@+id/okButton">


    <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toBottomOf="parent"
    >
       <LinearLayout android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="vertical">

        <TextView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"

                  android:text="temp"
                  android:padding="8dp"
                  android:id="@+id/explText"
        />
            <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_horizontal"
                    android:text="temp"
                    android:padding="4dp"
                    android:id="@+id/refText"
            />

        </LinearLayout>

    </ScrollView>

        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
                style="@style/CardViewStyle"
                android:layout_width="match_parent"


                android:id="@+id/okButton"
                android:layout_height="60dp"


                android:layout_marginBottom="4dp" app:layout_constraintBottom_toBottomOf="parent">

            <TextView
                    android:gravity="center"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:textSize="@dimen/btn_text_size"
                    android:text="Ok"/>

        </android.support.v7.widget.CardView>

Я пробовал полноэкранный фрагмент и получил тот же результат, поэтому диалодфрагмент не имеет значения.Я попробовал диф.Решения от Google, но только этот помог: я добавил

android:layout_marginTop="?android:attr/actionBarSize"

в ScrollView и получил весь текст.Но если я использую это решение, у меня будет нежелательное поле в случае, если текст small

Кто-нибудь знает, как это исправить?

...