2

その中に ScrollView と GridView があり、TextView を GridView の上に配置したいのですが、ユーザーがスクロールするまで表示されてはなりません。負のマージンについて考えましたが、負のマージンのときにスクロールを使用してこのビューを取得する方法を見つけることができませんでした。

基本的に:表示されるのはgridViewだけですが、ユーザーがgridViewの上にいてプルアップすると、TextViewが表示されるはずです。

編集:これの要点は、これからプルしてリフレッシュしたいということです。インターネットで人気のあるライブラリは、思い通りに動作しないため、使用したくありません。

編集2:

私は答えを得ましたが、私が達成しようとしていることは完全ではありません。非表示の TextView を (プルして更新するソリューションのように) スムーズに表示したいのですが、setVisibility を使用するとスムーズにすばやく表示できます。これが私のコードです:

XML :

<com.tas.android.quick.ui.controls.LockableScrollView
        android:id="@+id/scrollView"
        android:fillViewport="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

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

            <TextView 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/pullText"
                android:text="some text" />

            <com.tas.android.quick.ui.controls.ExpandableGridView
                android:id="@+id/gridview"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:clipToPadding="false"
                android:drawSelectorOnTop="true"
                android:fadingEdge="none"
                android:gravity="top"
                android:horizontalSpacing="@dimen/image_grid_hspacing"
                android:listSelector="@drawable/selector_shadow"
                android:numColumns="@integer/grid_num_cols"
                android:paddingBottom="50dp"
                android:scrollbarAlwaysDrawVerticalTrack="false"
                android:scrollbars="none"
                android:scrollingCache="true"
                android:smoothScrollbar="false"
                android:stretchMode="columnWidth"
                android:verticalSpacing="@dimen/image_grid_vspacing"
                android:visibility="visible" />
        </LinearLayout>
    </com.tas.android.quick.ui.controls.LockableScrollView>

そしてコード:

textview = (TextView) findViewById(R.id.pullText);
        textview.setVisibility(View.VISIBLE);

        scrollView = (LockableScrollView) findViewById(R.id.scrollView);

        scrollView.setScrollingEnabled(false);

...

gridView.setOnScrollListener(new OnScrollListener() {
                        @Override
                        public void onScrollStateChanged(AbsListView view, int scrollState) {
                            switch(scrollState) {
                            case 2: // SCROLL_STATE_FLING 
                                //hide button here
                                textview.setVisibility(View.VISIBLE);
                                break;

                            case 1: // SCROLL_STATE_TOUCH_SCROLL 
                                //hide button here
                                textview.setVisibility(View.GONE);
                                break;

                            case 0: // SCROLL_STATE_IDLE 
                                //show button here
                                textview.setVisibility(View.GONE);
                                break;
                            }
                        }

                        @Override
                        public void onScroll(AbsListView view, int firstVisibleItem,
                                int visibleItemCount, int totalItemCount) {
                                }
                            }
                        }
                    });
4

3 に答える 3

9

GridView と TextView の両方を LinearLayout (または RelativeLayout) 内に配置します。

次に、ScrollView に Linear/Relative レイアウトのみを含めます。

textview を非表示にするには、findViewById(R.id.textviewId).setVisibility(View.GONE);(View.VISIBLE を使用して再度表示するように設定します) を使用します。

于 2013-09-06T12:06:12.097 に答える
0

xml には可視性のためのオプションがあります。TextView をクリックし、それを Invisible または Gone に変更します。

于 2014-05-14T20:35:59.770 に答える