RelativeLayout的重心不工作 [英] RelativeLayout gravity center not working

查看:150
本文介绍了RelativeLayout的重心不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 RelativeLayout的这是一个基础。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    android:background="@android:color/transparent" >

这是行不通的。我已设置 centerInParent 真正的意见之一,而没有工作。不过,因为我有2次并排需要被集中在一起,我不能使用此解决方案。试图优化这个,所以我想避免嵌套布局,尤其是线性,彼此内部。

This isn't working. I have set centerInParent to true for one of the views and that did work. However, I can't use this solution because I have 2 views side by side that need to be centered together. Trying to optimize this so I want to avoid nesting layouts, especially Linear, inside of each other.

有没有办法,我失去了一些东西明显?我想这个属性对于这种情况的。

Is there something obvious that I'm missing? I thought this attribute is made for this situation.

推荐答案

所以,我对这个问题的修复变成只是利用的TextView的化合物,可绘制功能。我刚刚捣毁了按钮,用于drawableRight显示搜索图标。

So my fix for this issue turn out just to leverage the compound drawable feature of textview. I just trashed the button and used drawableRight to show the search icon.

这篇关于RelativeLayout的重心不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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