简体   繁体   English

滚动视图不起作用

[英]Scroll view does not work

I have a scroll view that I fill dynamicly in my code. 我有一个滚动视图,可以动态填充代码。 I expect if I put too much content to the parant view that the view becomes scrollable. 我希望如果我在parant视图中放置太多内容,该视图将变为可滚动的。 This does not work. 这是行不通的。

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

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_centerHorizontal="true"
            android:id="@+id/layoutScoreBoardHeader"
            android:layout_marginTop="15dp">

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/layoutScoreBoard"
            android:orientation="horizontal"
            android:layout_centerHorizontal="true"
            android:layout_below="@id/layoutScoreBoardHeader">

        </LinearLayout>

    </RelativeLayout>
</ScrollView>

Bad layout structure. 布局结构不良。 RelativeLayout should wrap_content. RelativeLayout应该wrap_content。 In your case it will be same size as initial ScrollView and it will ignore child size. 在您的情况下,其大小将与初始ScrollView相同,并且将忽略子级大小。

I have it. 我有 Did not know that there is a special view like horizontal scroll view. 不知道有没有类似水平滚动视图的特殊视图。 But thank you guys for your feedback! 但是谢谢你们的反馈!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM