滚动问题?

时间:2018-01-20 19:47:46

标签: android scroll

我的应用程序中有这个布局。它在正常/大屏幕上正确显示,但在较小的屏幕上无法滚动,无论我尝试过什么。

<ScrollView 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:fillViewport="true">

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:focusable="true"
    android:focusableInTouchMode="true"
    tools:layout_editor_absoluteY="25dp">

    <ImageView
        android:id='@+id/img'
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:contentDescription="@android:string/defaultMsisdnAlphaTag"
        android:scaleType="fitXY"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/bigImg" />

    <ImageView
        android:id="@+id/smallImg"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="44dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/smImg" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline4"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.53" />

    <android.support.v7.widget.GridLayout xmlns:grid="http://schemas.android.com/apk/res-auto"
        android:id="@+id/home_options"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:clipToPadding="true"
        android:paddingBottom="90dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/guideline4"
        grid:alignmentMode="alignBounds"
        grid:columnCount="3">

        <TextView
            android:layout_width="0dp"
            android:layout_height="112dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:drawablePadding="8dp"
            android:drawableTop="@android:mipmap/sym_def_app_icon"
            android:focusable="true"
            android:gravity="center"
            android:padding="1dp"
            android:text="item1"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#303436"
            grid:layout_columnWeight="1"
            grid:layout_gravity="fill_horizontal" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="112dp"
            android:clickable="true"
            android:drawablePadding="10dp"
            android:drawableTop="@android:mipmap/sym_def_app_icon"
            android:focusable="true"
            android:foreground="?attr/selectableItemBackground"
            android:gravity="center_horizontal"
            android:padding="1dp"
            android:text="item 2"
            android:textAppearance="?android:attr/textAppearanceSmall"
            grid:layout_columnWeight="1"
            grid:layout_gravity="fill_horizontal" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="112dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:drawablePadding="10dp"
            android:drawableTop="@android:mipmap/sym_def_app_icon"
            android:focusable="true"
            android:gravity="center_horizontal"
            android:padding="1dp"
            android:text="item 3"
            android:textAppearance="?android:attr/textAppearanceSmall"
            grid:layout_columnWeight="1"
            grid:layout_gravity="fill_horizontal" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="112dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:drawablePadding="10dp"
            android:drawableTop="@android:mipmap/sym_def_app_icon"
            android:focusable="true"
            android:gravity="center_horizontal"
            android:padding="1dp"
            android:text="item 4"
            android:textAppearance="?android:attr/textAppearanceSmall"
            grid:layout_columnWeight="1"
            grid:layout_gravity="fill_horizontal" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="112dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:drawablePadding="10dp"
            android:drawableTop="@android:mipmap/sym_def_app_icon"
            android:focusable="true"
            android:gravity="center_horizontal"
            android:padding="1dp"
            android:text="item 5"
            android:textAppearance="?android:attr/textAppearanceSmall"
            grid:layout_columnWeight="1"
            grid:layout_gravity="fill_horizontal" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="112dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:drawablePadding="10dp"
            android:drawableTop="@android:mipmap/sym_def_app_icon"
            android:focusable="true"
            android:gravity="center_horizontal"
            android:padding="1dp"
            android:text="item 6"
            android:textAppearance="?android:attr/textAppearanceSmall"
            grid:layout_columnWeight="1"
            grid:layout_gravity="fill_horizontal" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="112dp"
            android:background="?attr/selectableItemBackground"
            android:clickable="true"
            android:drawablePadding="10dp"
            android:drawableTop="@android:mipmap/sym_def_app_icon"
            android:focusable="true"
            android:gravity="center_horizontal"
            android:padding="1dp"
            android:text="item 7"
            android:textAppearance="?android:attr/textAppearanceSmall"
            grid:layout_columnWeight="1"
            grid:layout_gravity="fill_horizontal" />
    </android.support.v7.widget.GridLayout>

</android.support.constraint.ConstraintLayout>
</ScrollView>

此布局正在片段中使用。我有一个活动,它使用<CoordinatorLayout>布局和<FrameLayout>放置我的片段。其中一个片段具有上述xml布局。 我尝试过使用<NestedScrollview>,但问题仍然存在。

更新

活动具有以下布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">

<include layout="@layout/toolbar" />

<FrameLayout
    android:id="@+id/fragmentContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

任何人都可以分享任何想法吗?提前谢谢。

0 个答案:

没有答案