ScrollView可以滚动但子项的高度不足以使其滚动

时间:2017-06-15 08:59:05

标签: android

下面是我的布局:

yum -y install git

下面是我的代码:

 <ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:paddingBottom="20dp"
    android:scrollbarSize="0.5dp"
    android:scrollbars="vertical">

    <ViewAnimator
        android:id="@+id/animator"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="8dp"
                android:paddingLeft="12dp"
                android:paddingTop="18dp"
                android:text="content"
                android:textColor="#999"
                android:textSize="14sp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="8dp"
                android:paddingLeft="12dp"
                android:paddingTop="26dp"
                android:text="details"
                android:textColor="#999"
                android:textSize="24sp" />

            <include layout="@layout/divider" />

            <LinearLayout
                android:id="@+id/shop_receive"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:background="@color/white"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="16dp"
                android:paddingRight="16dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center_vertical"
                    android:text="shop receive"
                    android:textColor="#333"
                    android:textSize="16sp" />

                <RadioButton
                    android:id="@+id/shop_receive_radio"
                    android:layout_width="18dp"
                    android:layout_height="18dp"
                    android:background="@drawable/selector_radio"
                    android:button="@null" />
            </LinearLayout>

            <include layout="@layout/divider" />

            <LinearLayout
                android:id="@+id/send_post"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:background="@color/white"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="16dp"
                android:paddingRight="16dp">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center_vertical"
                    android:text="send post"
                    android:textColor="#333"
                    android:textSize="16sp" />

                <RadioButton
                    android:id="@+id/send_post_radio"
                    android:layout_width="18dp"
                    android:layout_height="18dp"
                    android:background="@drawable/selector_radio"
                    android:button="@null"
                    android:checked="true" />
            </LinearLayout>

            <include layout="@layout/divider" />

            <android.support.v4.widget.Space
                android:layout_width="wrap_content"
                android:layout_height="@dimen/dp60" />

            <TextView
                android:id="@+id/btn_next"
                style="@style/ButtonTheme"
                android:text="next" />
        </LinearLayout>

        <ViewStub
            android:id="@+id/send_post_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout="@layout/layout_send_post" />

        <ViewStub
            android:id="@+id/shop_receive_stub"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout="@layout/layout_shop_receive" />
    </ViewAnimator>
</ScrollView>

下面是layout_shop_receive:

的布局
next.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (sendPostRadio.isChecked()) {
                initSendPostLayout();  //init the first viewstub and show it
                animator.setDisplayedChild(1);
            }

            if (shopReceiveRadio.isChecked()) {
                initShopReceiveLayout(); //init the second viewstub and show
                animator.setDisplayedChild(2);
            }
        }
    });

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (KeyEvent.KEYCODE_BACK == keyCode) {
        int child = animator.getDisplayedChild();
        if (0 == child) {
            finish();
        } else {
            animator.setDisplayedChild(0);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
下面的

是XListView类:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="34dp">

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="12dp"
    android:paddingLeft="12dp"
    android:text="领取地址" />

<XListView
    android:id="@+id/receive_address"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white" />

<TextView
    android:id="@+id/ok"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:marginTop="25dp"
    android:text="ok" />
</LinearLayout>

}

当显示商店收到布局时,列表视图的高度足够大,滚动视图可以滚动,但当我按回显示viewanimator的第一个孩子时,滚动视图仍然可以滚动,但是第一个视图的孩子&#39 ; s高度很小,一个屏幕可以容纳所有第一个孩子,为什么scrollview仍然可以滚动?

0 个答案:

没有答案