android实现底部布局往往使用RelativeLayout的布局方式,并且设置android:layout_alignParentBottom=”true”,这样很容易实现底部布局。然而对于比较复杂的布局简单的属性设置无法达到这样的效果,例如top,center,bottom三层的布局,很可能因为中间层(center)的数据太多而将无法显示全或者将bottom层挤下去。解决这个问题,在采用RelativeLayout布局时,除了设置android:layout_alignParentBottom=”true”外,还需要对中间层进行属性进行设置:android:layout_above=”@id/bottom” android:layout_below=”@id/top”。这样的设置即确保center层能处于中间位置,也可以通过自适应显示滚动条。 以下的例子就是实现三层布局的底部布局的功能。如图1,2。 图-1 三层的底部布局界面 图 2 弹出输入法时显示的底部按钮 项目只是实现主要的数据填充及布局,故只是简单的文件加载。以下是源码: 1.BottomTestActivity.java
2.main.xml
3.item.xml
|
android实现底部按钮布局
最新推荐文章于 2024-07-28 23:44:14 发布
android实现底部布局往往使用RelativeLayout的布局方式,并且设置android:layout_alignParentBottom=”true”,这样很容易实现底部布局。然而对于比较复杂的布局简单的属性设置无法达到这样的效果,例如top,center,bottom三层的布局,很可能因为中间层(center)的数据太多而将无法显示全或者将bottom层挤下去。解决这个问题,在采用RelativeLayout布局时,除了设置android:layout_alignParentBottom=”true”外,还需要对中间层进行属性进行设置:android:layout_above=”@id/bottom” android:layout_below=”@id/top”。这样的设置即确保center层能处于中间位置,也可以通过自适应显示滚动条。 以下的例子就是实现三层布局的底部布局的功能。如图1,2。 图-1 三层的底部布局界面 图 2 弹出输入法时显示的底部按钮 项目只是实现主要的数据填充及布局,故只是简单的文件加载。以下是源码: 1.BottomTestActivity.java 主要布局文件 2.main.xml listview item内容的布局文件 3.item.xml 源码下载: BottomTest.zip |