【问题标题】:Positioning a bottom element at vertical center将底部元素定位在垂直中心
【发布时间】:2018-08-09 11:31:43
【问题描述】:

我试图到处搜索,但什么也没有。

RelativeLayout 中没有任何问题可以将任何东西定位到中心

android:gravity="center_horizontal|center_vertical"

但我想将我的按钮图像底部定位到中心,使其位于中心线上方..

如何对任何尺寸的屏幕和按钮执行此操作,或者我必须知道按钮的大小?

【问题讨论】:

  • 你可以试试android:layout_centerInParent=true
  • 分享你所做的xml代码
  • 这一切都很好,但没有人明白...我不希望那张图片在中心但在中心之上.. 像 imageY = displayheight/2+imageHeight/2 我不知道如何解释它更多..

标签: android layout position center


【解决方案1】:

使用下面的代码

<ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"/>

【讨论】:

    猜你喜欢
    • 2018-12-12
    • 2014-01-29
    • 2017-01-30
    • 2015-05-02
    • 2014-06-25
    • 2022-12-11
    • 1970-01-01
    • 2015-07-10
    • 2015-03-31
    相关资源
    最近更新 更多