【发布时间】:2017-06-05 13:23:04
【问题描述】:
我从 2 天前开始尝试创建这个简单的布局: 它并不完全相等,但它接近我想要的。
当我尝试在我的约束布局上设置滚动视图时,我总是很乱
即使我限制了我所有的元素,我现在也不知道如何组织这些东西,我真的很困惑。
这是我的 xml:
<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="wrap_content"
tools:context=".PhotosForPlant">
<android.support.constraint.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="match_parent"
tools:context="com.example.afcosta.inesctec.pt.android.PhotosForPlant"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp">
<ImageView
android:id="@+id/plantImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/color_cursor_white"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="41dp" />
<TextView
android:id="@+id/descricaoTit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrição"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="582dp" />
<TextView
android:id="@+id/specieDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="622dp" />
<TextView
android:id="@+id/Family"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Familia"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="458dp" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Genre"
tools:layout_editor_absoluteX="24dp"
tools:layout_editor_absoluteY="389dp" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Espécie"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="309dp" />
<TextView
android:id="@+id/FamilyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="96dp"
tools:layout_editor_absoluteY="458dp" />
<TextView
android:id="@+id/GenreName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="96dp"
tools:layout_editor_absoluteY="389dp" />
<TextView
android:id="@+id/SpecieName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="96dp"
tools:layout_editor_absoluteY="309dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/gallery"
android:layout_width="408dp"
android:layout_height="111dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="141dp" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
【问题讨论】:
-
使用 NestedScrollView 而不是 ScrollView。
-
你能举个例子吗?
-
我只需要 1 个滚动条,为什么要嵌套?
-
参考这个stackoverflow.com/questions/43098150/…也许你会得到解决方案
-
我在你的布局中看不到任何约束,你没有为视图设置约束,它们不会正确定位通过这个developer.android.com/reference/android/support/constraint/…
标签: java android xml android-layout layout