作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我是 android 中布局结构的新手,我的任务是构建一个底部有一个按钮(也居中水平)的 Activity ,按钮底部和底部之间有一点填充可见屏幕。
挑战在于如何在相对布局中做到这一点,并使它无论屏幕尺寸如何都锚定到同一位置
如果有人能指出正确的方向,那就太好了!
最佳答案
dev docs有一些示例布局和 API Demos项目也很棒。
下面的布局会将按钮放在底部,但请记住,当您向相对布局添加更多控件时,它们必须相互尊重。像 layout_above 这个按钮或者把这个按钮放在最后,并确保它有一个像 android:layout_below="id_of_other_bottommost_controll"
这样的属性<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:text="button"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
关于android - 如何将按钮锚定在android中相对布局的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6285320/
我是一名优秀的程序员,十分优秀!