滚动视图和水平滚动视图中的微调器选择

时间:2013-07-03 11:57:57

标签: android scrollview android-spinner horizontal-scrolling android-scrollview

我在scrollview和horizo​​ntal 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="horizontal" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="beforeDescendants"
        android:fillViewport="true"
        android:focusableInTouchMode="false" >

        <HorizontalScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:fillViewport="true" >

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/scroll_border" >

                <RelativeLayout
                    android:id="@+id/rootRelative"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dp"
                    android:background="@drawable/contnent_border"
                    android:padding="5dp" >

                    <!-- reporter Detail layout -->

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

                        <include layout="@layout/general_reporter_detail" />
                    </LinearLayout>

                    <!-- start of occurence detail tenLinear -->

                    <LinearLayout
                        android:id="@+id/occurenceDetail"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/reporterLayout" >

                        <include layout="@layout/occurence_detail_flying_operation" />
                    </LinearLayout>

                </RelativeLayout>
            </RelativeLayout>
        </HorizontalScrollView>
    </ScrollView>

</LinearLayout>

如果有人有解决方案,请帮助我。

3 个答案:

答案 0 :(得分:0)

您是否尝试过此链接中提到的解决方案:Similar problem with ListView

答案 1 :(得分:0)

尝试this SO答案

的解决方案

效果很好:

// save index and top position
int index = mList.getFirstVisiblePosition();
View v = mList.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();

// ...

// restore
mList.setSelectionFromTop(index, top);

答案 2 :(得分:0)

在布局中使用自定义微调器,使用完全限定名称作为defult spinner标签的intead,并在水平scrollview.it中使用此自定义微调器为我工作

相关问题