1

我正在使用一个配置面板的布局,该面板包含一个包含两个子视图的 LinearLayout (垂直):一个主子视图,它是一个 ScrollView (它有很多东西 - 超过屏幕上的大小,所以我使用ScrollView 来处理它)和一个面板,当配置面板中的某些内容发生更改时出现的面板(通常的东西:一个保存按钮和一个恢复按钮)。问题是我无法说服 ScrollView 缩小以允许“保存/恢复”面板在屏幕上的任何空间。

这是布局文件的摘录:[编辑:添加的 ScrollView 内容]

<LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="vertical">

    <ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/scrollView">

            <TextView
                    style="?android:listSeparatorTextViewStyle"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/tweeterLK_options"
                    android:layout_marginTop="15sp"
                    android:id="@+id/textView5"/>

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

                <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fgIntervalPrompt"
                        android:id="@+id/fgEnable"
                        android:checked="true"
                        android:paddingRight="5dp"/>

                <Spinner
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/fgInterval"/>
            </LinearLayout>

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

                <CheckBox android:id="@+id/bgEnable"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="@string/bgIntervalPrompt"
                          android:checked="true"
                        />

                <Spinner android:id="@+id/bgInterval"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:prompt="@string/bgIntervalPrompt"/>

            </LinearLayout>

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

                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:text="@string/tlkConfig_cacheDepth_prompt"
                        android:id="@+id/textView"
                        android:layout_gravity="center_vertical"
                        android:layout_marginRight="10dp"/>

                <Spinner
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/cacheDepth"
                        android:prompt="@string/tlkConfig_cacheDepth_prompt"
                        />

            </LinearLayout>

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

                <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/tlkConfig_preload_avatar"
                        android:id="@+id/preload_avatar"
                        android:checked="true"
                        android:layout_weight="1"/>

                <CheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/tlkConfig_preload_images"
                        android:id="@+id/preload_images"
                        android:checked="false"
                        android:layout_weight="1"/>
            </LinearLayout>

        </LinearLayout>

        <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:visibility="visible">

            <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/account"
                    style="?android:listSeparatorTextViewStyle"
                    android:layout_marginTop="15sp"
                    />

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

            <Button android:id="@+id/sign_in"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sign_in"
                    android:visibility="gone"/>

            <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sign_out"
                    android:id="@+id/sign_out_button"
                    android:visibility="visible"/>
        </LinearLayout>

        <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">

            <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/lk_options_header"
                    style="?android:listSeparatorTextViewStyle"
                    android:layout_marginTop="14sp"
                    />

            <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/lkServer_enableLK"
                    android:id="@+id/lkServer_enable"
                    android:checked="false"/>

            <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:id="@+id/lkServer_selection">

                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:text="@string/lkServer_serverListLabel"
                        android:id="@+id/lkServerLabel"
                        android:layout_gravity="center_vertical"
                        android:layout_marginRight="3dp"/>

                <Spinner android:id="@+id/lkServerSpinner"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:prompt="@string/lkServerSpinnerPrompt"
                         android:longClickable="true"/>
            </LinearLayout>

            <CheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/lkServer_inUse"
                    android:id="@+id/lkServer_useRecommendation"
                    android:checked="false"/>
        </LinearLayout>

    </ScrollView>

    <LinearLayout android:id="@+id/settings_changed"
                  android:orientation="horizontal"
                  android:layout_width="wrap_content"
                  android:layout_height="0dip"
                  android:layout_weight="1"
                  android:visibility="gone">
            <Button android:id="@+id/save"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="@string/save_settings"
                />
        <Button android:id="@+id/revert"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="@string/reset_settings"
                />
    </LinearLayout>
</LinearLayout>

当我使@id/save布局可见(使用setVisibility(View.VISIBLE))时,它不会导致 ScrollView 调整大小。关于为什么会这样以及我应该怎么做的任何想法?

我有 2 个选项:a) 修复滚动视图的大小,以便它始终为面板留出空间,或者 b) 摆脱面板并在按下后退按钮时弹出一个对话框。我更喜欢第二个,主要是因为我已经开始工作了。

4

1 回答 1

-1

滚动视图中没有内容。请添加内容

<ScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/scrollView">


//Place your layouts and contents here for things to get scroll


</ScrollView>
于 2013-08-22T05:55:24.737 回答