gpt4 book ai didi

android - 布局与另一个布局重叠的问题

转载 作者:行者123 更新时间:2023-11-30 03:11:19 28 4
gpt4 key购买 nike

我正在尝试使用屏幕底部的按钮获得线性布局。我有一个主要的父线性布局,它包含一个 ScrollView 和一个线性布局。 ScrollView 似乎将线性布局推离了屏幕。

我已经尝试使用所有布局宽度/高度属性。但一切看起来都很好,我什至用像素完美检查过它,但它没有显示任何有用的东西。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp"
>

<ScrollView

android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:id="@+id/layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_title"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/image_title"
android:textAppearance="?android:attr/textAppearanceMedium" />

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/pia04980"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/descp"
android:textAppearance="?android:attr/textAppearanceSmall" />

</LinearLayout>

</ScrollView>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center"
android:padding="5dp"
android:orientation="horizontal" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Refresh" />
</LinearLayout>

</LinearLayout>

string descp 很长,这就是为什么 ScrollView 会填满整个屏幕而没有给其他线性布局留下空间的原因。

最佳答案

目前,ScrollView 的高度由其内容决定。您可能希望它占用其父级的所有额外垂直空间,并滚动其内容。为此,将其设置为:

<ScrollView
android:id="@+id/scrollView1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp" >

关于android - 布局与另一个布局重叠的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20928911/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com