天天看点

ScrollView滚动条去除,底部有其他控件时不显示滚动条

去除滚动条的话直接设置scrollview属性 android:scrollbars="none"就可以了
底部有控件的话,设置scrollview属性,layout_above="@+id/底部控件id"
如:android:layout_above="@+id/button_btn_xiangqing"
页面模板如下
<?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">

    <RelativeLayout
        android:id="@+id/top"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fff"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/header_xiangqing"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginTop="20dp">

            <TextView
                android:id="@+id/xiangqingye"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="商品详情"
                android:textColor="#333333"
                android:textSize="18sp" />

            <ImageView
                android:id="@+id/back_icons"
                android:layout_width="22dp"
                android:layout_height="22dp"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="8dp"
                android:background="@drawable/login_back" />

        </RelativeLayout>

        <ScrollView
            android:layout_marginTop="10dp"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none"
            android:layout_below="@+id/top"
            android:layout_above="@+id/button_btn_xiangqing">

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

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="70dp"
                    android:background="#fff"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/tit_desc_xiangqing"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/shop_icons"
                        android:layout_marginLeft="8dp"
                        android:layout_marginTop="8dp"
                        android:text="韩版胸包 单肩男包斜跨包男士腰包胸前包帆布运动
休闲男手机挎包 "
                        android:textColor="#000"
                        android:textSize="16sp" />

                    <LinearLayout
                        android:id="@+id/price"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_below="@+id/tit_desc_xiangqing"
                        android:layout_marginLeft="8dp"
                        android:layout_marginTop="9dp"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/price_xiangqing"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="¥69.00"
                            android:textColor="#CC0001"
                            android:textSize="18sp" />

                        <FrameLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="2dp">

                            <View
                                android:layout_width="50dp"
                                android:layout_height="1dp"
                                android:layout_marginTop="10dp"
                                android:background="#999999" />

                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="¥80.00" />
                        </FrameLayout>

                    </LinearLayout>

                    <View
                        android:id="@+id/xian1"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@id/price"
                        android:layout_marginTop="8dp"
                        android:background="#dfdfdf" />

                    <LinearLayout
                        android:id="@+id/travel"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_alignLeft="@+id/price"
                        android:layout_alignStart="@+id/price"
                        android:layout_below="@+id/xian1"
                        android:layout_marginTop="15dp">

                        <TextView
                            android:id="@+id/bai"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="运费" />

                        <TextView
                            android:id="@+id/bai_text"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignBaseline="@+id/bai"
                            android:layout_alignBottom="@+id/bai"
                            android:layout_marginLeft="18dp"
                            android:layout_marginStart="18dp"
                            android:layout_toEndOf="@+id/bai"
                            android:layout_toRightOf="@+id/bai"
                            android:text="¥6.00"
                            android:textColor="#999999" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/choose_message"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_alignLeft="@+id/travel"
                        android:layout_alignStart="@+id/travel"
                        android:layout_below="@+id/travel"
                        android:layout_marginTop="15dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/choose"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginLeft="5dp"
                            android:gravity="center_vertical"
                            android:text="选择"
                            android:textColor="#333333"
                            android:textSize="14sp" />

                        <TextView
                            android:id="@+id/choose_text"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginLeft="20dp"
                            android:gravity="center_vertical"
                            android:text="产品规格"
                            android:textColor="#333333"
                            android:textSize="14sp" />

                        <Button
                            android:layout_width="0dp"
                            android:layout_height="match_parent"
                            android:layout_weight="1.0"
                            android:alpha="0" />

                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="5dp"
                            android:gravity="center_horizontal"
                            android:src="@drawable/shop_message" />
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/canshu"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_alignLeft="@+id/choose_message"
                        android:layout_alignStart="@+id/choose_message"
                        android:layout_below="@+id/choose_message"
                        android:layout_marginTop="15dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/cans"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:gravity="center_vertical"
                            android:text="参数"
                            android:textColor="#333333"
                            android:textSize="14sp" />

                        <Button
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1.0"
                            android:alpha="0" />

                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="5dp"
                            android:gravity="center_horizontal"
                            android:src="@drawable/shop_message" />
                    </LinearLayout>

                    <ImageView
                        android:id="@+id/shop_icons"
                        android:layout_width="300dp"
                        android:layout_height="280dp"
                        android:layout_centerHorizontal="true"
                        android:src="@drawable/bg" />

                    <View
                        android:id="@+id/line"
                        android:layout_width="match_parent"
                        android:layout_height="20dp"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:layout_below="@+id/travel"
                        android:background="#f9f9f9" />
                </RelativeLayout>
            </LinearLayout>
        </ScrollView>

        <RelativeLayout
            android:id="@+id/button_btn_xiangqing"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="#fff">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:gravity="center"
                android:orientation="horizontal">

                <ImageView
                    android:id="@+id/kefu"
                    android:layout_width="23dp"
                    android:layout_height="23dp"
                    android:layout_marginLeft="20dp"
                    android:src="@drawable/shop_kefu" />

                <View
                    android:layout_width="1dp"
                    android:layout_height="23dp"
                    android:layout_marginLeft="20dp"
                    android:background="#cccccc" />

                <ImageView
                    android:layout_width="23dp"
                    android:layout_height="23dp"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="20dp"
                    android:src="@drawable/shop_car" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_alignParentRight="true"
                android:orientation="horizontal">

                <Button
                    android:id="@+id/add_cars"
                    android:layout_width="120dp"
                    android:layout_height="match_parent"
                    android:layout_alignParentLeft="@+id/buy"
                    android:background="#ff9999"
                    android:gravity="center"
                    android:text="加入购物车"
                    android:textColor="#fff"
                    android:textSize="16sp" />

                <Button
                    android:id="@+id/buy"
                    android:layout_width="120dp"
                    android:layout_height="match_parent"
                    android:background="#f00"
                    android:gravity="center"
                    android:text="加入购物车"
                    android:textColor="#fff"
                    android:textSize="16sp" />
            </LinearLayout>
        </RelativeLayout>
    </RelativeLayout>
</LinearLayout>