如何在android的相对布局的底部锚定按钮 [英] How to anchor a button at the bottom of a relative layout in android

查看:895
本文介绍了如何在android的相对布局的底部锚定按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的android系统的布局结构,我用填充按钮的底部和底部之间有一个小一点的建筑,在底部的一个按钮(居中HORIZ为好)活动负责的可视屏幕。

I'm new to the layout structure in android and I'm tasked with building an activity that has a button at the bottom (centered horiz as well) with a small bit of padding between the bottom of the button and the bottom of the visible screen.

目前的挑战是如何做到这一点的相对布局,使之锚定到同一个点,无论屏幕尺寸

The challenge is how to do this in relative layout and make it anchor to the same spot regardless of screen size

如果任何人都可以点我在正确的方向,这将是伟大的!

If anyone can point me in the right direction that would be great!

推荐答案

借助开发文档有一些样品布局和 API演示项目是伟大的。

The dev docs have some sample layouts and the API Demos project is great too.

布局下面会把底部按钮,但要记住当你添加更多的控制到相对布局,他们将不得不互相尊重。像layout_above此按钮或把这个按钮结束,并确保它具有像Android这样一个属性:layout_below =id_of_other_bottommost_controll

The layout below will put the button at the bottom, but remember as you add more controls to a relative layout they will have to respect each other. like layout_above this button or put this button at the end and make sure it has an attribute like 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的相对布局的底部锚定按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆