如何解决Android Studio XML格式未填满屏幕
我正在开发第一个应用程序。该应用程序的一项活动包括向左和向右滑动以滚动浏览不同的片段,为此我正在使用Scroll-View。我希望每个片段都包含多个元素,但是不幸的是,Scroll-View仅支持最多一个直接子元素。要解决此问题,我将所需的所有视图放在ConstraintLayout的片段中,使ConstraintLayout成为ScrollView的唯一直接子级。您可以在下面的XML代码中看到这一点:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gayLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<A BUNCH OF CHILD VIEWS (ImageViews,TextViews,etc.)/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
不幸的是,这完全弄乱了格式。您可以在下面的图片中看到它:
在所有视图下方的渲染中可以看到一条蓝线。据我所知,这是内部约束布局的底部边缘,但事实是,我不知道如何移动它,也无法将其任何子元素移动到该线下方。我可以将其缩小,而不能放大,也无法将其缩放到不同的屏幕尺寸。没有这些问题,将这些子元素分组的更好方法是什么?谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。