当使用API​​ 17进行渲染时,Android Button文本不会居中 [英] Android Button text not centered when using API 17 for rendering

查看:138
本文介绍了当使用API​​ 17进行渲染时,Android Button文本不会居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在布局的图形视图中,当我从下面的图片中显示的按钮选择API 15或更低版本时,包围的按钮中的文本看起来很好。

In the graphical view of layout, when I choose API 15 or lower from the button shown in the image below, the text in the encircled buttons looks fine.

当我选择API 17即使xml代码相同,文本也会移位。更改按钮填充没有帮助。

When I choose API 17, the text is displaced even though the xml code is same. Changing the button padding does not help.

这只是Eclipse的一个问题,或者新版本的Android可能会看到这个替换的文本?

Is this just a problem with Eclipse or is it possible that new versions of android may see this displaced text?

解决此问题的方法有哪些?

What's the workaround to fix this?

XML代码:

<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=".HomeActivity" >

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_margin="3dp" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:src="@drawable/label" />
</LinearLayout>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/linearLayout1"
    android:layout_below="@+id/linearLayout1"
    android:layout_marginTop="20dp"
    android:text="@string/about_title"
    android:textSize="20sp" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignRight="@+id/linearLayout1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="5dp"
    android:text="@string/temp" />

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView2"
    android:layout_alignRight="@+id/textView2"
    android:layout_below="@+id/textView2"
    android:layout_marginTop="20dp"
    android:baselineAligned="false" >

    <Button
        android:id="@+id/button1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/news" />

    <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/tournaments" />

    <Button
        android:id="@+id/button3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/results" />
</LinearLayout>

推荐答案

android:gravity =center没有帮助

我重新启动了两次eclipse。奇怪的是,它在第​​一次重启时没有帮助,但在第二次重新启动后看起来很好。此外,它的工作在设备上。
对此问题抱歉,我必须等待才发布问题。

I restarted eclipse twice. Strangely it did not help in the first restart but it looked fine after the second one. Also, its working fine on device. Apologies for the question, I must have waited before posting the question.

这篇关于当使用API​​ 17进行渲染时,Android Button文本不会居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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