【问题标题】:Is that possible to Accommodate Spinner inside Scroll View?是否可以在滚动视图中容纳微调器?
【发布时间】:2012-10-17 09:29:24
【问题描述】:

我正在尝试在 Scroll View 中容纳 4 个微调器。但我将无法做到这一点。 有什么办法可以在 Scroll View 中容纳微调器??

【问题讨论】:

    标签: android android-layout android-widget


    【解决方案1】:

    简单: ScrollView 只能容纳一个直接的孩子,所以如果你把微调器放在 LinearLayout 里面,一切都会好起来的。

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
    
        <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
    
                <Spinner
                    android:id="@+id/spinner2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
    
                <Spinner
                    android:id="@+id/spinner1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
    
                <Spinner
                    android:id="@+id/spinner3"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
    
                <Spinner
                    android:id="@+id/spinner4"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1" />
    
            </LinearLayout>
        </ScrollView>
    
    </LinearLayout>
    

    【讨论】:

    • 是否可以将微调器放置在水平滚动视图中并让它们彼此相邻?
    • 是的,为什么不呢。
    猜你喜欢
    • 1970-01-01
    • 2016-12-24
    • 2013-07-01
    • 1970-01-01
    • 2018-08-19
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 2020-09-01
    相关资源
    最近更新 更多