第一次写博客,记录自己在日常开发中用到的实用的技术和技巧,与各位共享;
最近在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;