android - 在 android 中的 scrollView 之后没有小部件显示

标签 android scrollview

我的设计是这样的:“Linearlayout start”“scrollview start”“scrollview end”“LinearLayout start”“LinearLayout end”“LinearLayout end”。但是第二个线性布局没有显示在屏幕上。

代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    >
    <ScrollView 
            android:fillViewport="false"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" >
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/title" />
            <TextView
                android:id="@+id/date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/date" />
            <ImageView
                android:id="@+id/imageView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/nasa" />

                <TextView
                android:id="@+id/description"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/description" />

        </LinearLayout>

    </ScrollView>
    <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center">
        <Button android:id="@+id/refresh" android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="@string/refresh">     
        </Button>
    </LinearLayout>
</LinearLayout>

提前致谢

最佳答案

我找到了解决方案。我需要在 ScrollView 中添加一个额外的属性

<ScrollView android:layout_weight="1">

防止滚动条填满整个屏幕。

关于android - 在 android 中的 scrollView 之后没有小部件显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10869554/

相关文章:

android listview 页脚宽度更改为匹配父级本身

android - 为什么我的Firebase没有从项目结构中添加?

android - 有没有办法让保留的 fragment 知道屏幕方向何时改变?

android - ScrollView 中的可缩放 TextView

react-native - ScrollView 中的 style 与 contentContainerStyle?

android - TextView 不适合 ScrollView

android - onCreateOptionsMenu 没有在 Fragment 中被调用

java - 如何在 TextView 中使用 ClickableSpans 并且仍然能够水平滚动?

android - ScrollView 不显示某些 UI 元素

android - 如何在 View 设置为可见/消失时调整布局大小