Android – ScrollView下面是按钮栏,ScrollView上面是说明

  • 问题引入

设计布局时会用到scrollview的排版:ScrollView下面是按钮栏,ScrollView上面是说明,下面介绍一个方式来实现。
(有需要的可以直接新建一个xml文档,复制代码看看效果可以一试 )
1.用到相对布局,在ScrollView里放置自己的内容
2.整体为三段式,上面是标题,中间一个ScrollView,下面是按钮
如下代码:

    <!--android:layout_gravity="start" 左侧划出,end 右侧-->
    <RelativeLayout
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@color/leftSide_bg_color"
        android:layout_gravity="start">

        <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="50dp"
               android:layout_alignParentTop="true"
               android:gravity="center"
               >
                <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/leftSide_btn_color"
                android:text="历史记录"
                />
           </LinearLayout>

        <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/fileList"
                android:layout_marginTop="55dp"
                android:layout_marginBottom="55dp"
                >
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/sc_layout"
                    android:orientation="vertical"
                    >

                </LinearLayout>
            </ScrollView>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:orientation="horizontal"
            android:layout_alignParentBottom="true"
            >
            <Button android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/leftSide_btn_color"
                android:onClick="contactMe"
                android:layout_gravity="bottom"
                android:text="联系我" />
        </LinearLayout>
    </RelativeLayout>
  • 说明:
    核心代码为scrollview里的和上下两个部分设置的android:layout_height="50dp"
    android:layout_alignParentBottom="true" android:layout_alignParentTop="true"
                android:layout_marginTop="55dp"
                android:layout_marginBottom="55dp"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林深人不知

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值