【问题标题】:Android Button Text Starts After Center Of ButtonAndroid 按钮文本在按钮中心之后开始
【发布时间】:2012-12-10 05:40:04
【问题描述】:

我的布局中的按钮有问题。每当我添加一个按钮时,文本都会在按钮中心之后开始。

这就是我的意思:

我使用的是Relativelayout,但我使用Linearrelativetable 并不重要。 宽度和高度设置为 wrap_content。

我会非常感谢任何形式的帮助。

【问题讨论】:

  • 你在做什么工作? CSS?安卓?真的需要更多细节
  • 发布您的 xml,希望您没有在 android:text 中插入空格
  • 安卓。 @Gaurav 我为什么要这样做?
  • 您介意发布您的 xml 吗?
  • 遇到了同样的问题。关闭并重新打开我的 IDE 并自行修复。

标签: android button text center


【解决方案1】:

试试这个 android:gravity="left"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<Button
    android:id="@+id/button"
    android:layout_width="fill_parent"
    android:layout_height="200dp"
    android:gravity="left"
    android:text="Button" />

【讨论】:

  • 非常感谢,我没想到!此外,这似乎只是 xml 文件的图形预览中的问题。在调试时,无论有无重力,它似乎都可以正常工作,但很烦人。
【解决方案2】:

当我遇到这个问题时,它是 Eclipse GUI 设计器的问题。 Eclipse 重启应该会有所帮助。

【讨论】:

    猜你喜欢
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    • 1970-01-01
    • 2011-05-10
    • 1970-01-01
    相关资源
    最近更新 更多