【发布时间】:2019-04-16 05:18:31
【问题描述】:
我想放置一个滚动视图来滚动屏幕上的内容,但我不明白我在这里做错了什么。任何帮助将不胜感激。我是否需要将约束布局放在线性布局中,然后将线性视图放在滚动视图中,或者我在这里做错了什么?
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:id="@+id/layout_fragment_head"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/color_theme_main_dark"
app:layout_constraintBottom_toTopOf="@+id/guideline15"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
// I edited the code here for simplicity
</android.support.constraint.ConstraintLayout>
<fragment
android:id="@+id/fragment_deviceslist"
android:name="com.resatech.android.scoutandroid.master.fragments.DevicesListFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline15"
tools:layout="@layout/fragment_devices_list" />
<android.support.constraint.Guideline
android:id="@+id/guideline15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".3" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
【问题讨论】:
-
你可能想看看这个,因为滚动视图内的约束布局似乎存在一些困难:stackoverflow.com/questions/37349845/…
-
我做了但仍然没有帮助:/
-
scrollView 应该只包含一个子 View,否则使用 Nested ScrollView
标签: android user-interface scrollview