如何在UI底部的固定位置设置按钮? [英] how to set a button at a fixed location on the bottom of UI?

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

问题描述

我希望按钮始终始终显示在UI的页脚中的固定位置?(总是,如果它上面有组件,则没有)

I want a button to appear at fixed location all the time, in the footer of the UI ؟ ( always, if it has components above it or not )

推荐答案

请在主布局下采用一种相对布局.将其高度和宽度设置为填充父级,将其重力设置为底部,然后在其中放置任何textview或任何按钮.

Please take one Relative layout under your main layout . Set its height and width as fill parent and set its gravity as bottom and put any textview or any button you want in it.

 <?xml version="1.0" encoding="utf-8"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">

    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:gravity="bottom">

        <Button 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Bottom Gravity" />

    </RelativeLayout>

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <Button 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="Without Gravity" />

    </LinearLayout>

</FrameLayout>

这篇关于如何在UI底部的固定位置设置按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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