安卓常用的三行布局

本文介绍了一种在App开发中实现资讯详情页面的高效布局方法,采用RelativeLayout配合ScrollView实现了自适应高度且不会覆盖底部布局的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一次写博客,记录自己在日常开发中用到的实用的技术和技巧,与各位共享;

最近在app开发当中涉及到资讯方面的布局,举个例子?


在上面这个新闻详情界面,布局就是标准的三行布局: 上面一个titlebar,中间是content,下面是交互;

类似这样的布局,快速而高效的就是利用RelativeLayout:

最上方是一个自定义的titlebar,当然换成你喜欢xxbar都可以

<include layout="@layout/title_bar"/>
中面是个scrollview,其中需要below我们的titlebar,还需要above我们下边的交互栏

<ScrollView
    android:layout_above="@+id/ll_introduce"
    android:layout_below="@+id/title_bar"
    android:id="@+id/news_scrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
最后是我们的交互布局,只需要alignParentBottom,因为我们的scrollview滑动的同时也需要沉底

<LinearLayout
    android:id="@+id/ll_introduce"
    android:focusableInTouchMode="true"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
大功告成,是不是很简单,这样做的好处是高度自适应,并且不会覆盖我们的底部布局,over;





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值