按钮文字移位的问题 [英] Issue with button text shifting
问题描述
我遇到这个奇怪的问题.我有这些按钮,在某些操作下按钮的文本向下移动.例如,我有一个带有选项的微调器,其中一个选项使某些按钮不可见,而另一些则变为可见.当我选择这些按钮时,所有可见的按钮的文本都向下移动.除了按钮上的文字,其他都没有改变.我已经在1.5上试过了,它工作正常,没有文本被移动,但是我在2.1上有问题,我真的无法弄清楚.任何想法或帮助都会很棒.谢谢.
I'm having this odd issue. I have these buttons where the button's text is shifted downward upon certain actions. For example, I have a spinner with choices and one of the choices makes some buttons invisible while others are made visible. When I choose these, the buttons made visible all have their text shifted downward. Nothing else is shifted, just the text on the buttons. I've tried this on 1.5 and it works fine, no text is shifted, but I have issues with 2.1 and I really cannot figure it out. Any ideas or help would be great. Thanks.
这是文件的xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout android:id="@+id/testpracHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<!-- android:background="#ff0000"-->
<TableRow>
<Spinner android:id="@+id/testprac_menu"
android:layout_width="200px"
android:layout_height="wrap_content"></Spinner>
<View android:id="@+id/header_space_buffer"
android:layout_width="40px"
android:layout_height="30px"
android:gravity="center"></View>
<Button android:text="New"
android:id="@+id/newInterval"
android:layout_width="80px"
android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
<TableLayout android:id="@+id/bottomStruct"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TableRow>
<Button android:layout_width="80px"
android:text="Replay"
android:id="@+id/replay"
android:layout_height="wrap_content"></Button>
<Button android:id="@+id/playInterval"
android:text="Play"
android:layout_width="160px"
android:layout_height="wrap_content"></Button>
<Button android:text="Submit"
android:id="@+id/submit"
android:layout_width="80px"
android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</RelativeLayout>
当我使用 testprac
微调器时,重播,新建和提交按钮不可见,并且播放按钮变为可见(这就是我想要的).这似乎是问题似乎开始的时候.播放按钮的文本完全消失了(很可能移到较低的位置才能看到),当我回到其他按钮的可见状态时,我看到了如下所示的问题.左侧是使用微调器之前的问题,右侧是问题.我不知道是不是造成这种情况的微调器.
When i use the testprac
spinner, the replay, new and submit buttons go invisible and the play button becomes visible (which is what I want). This seems to be when the issue seems to start. The play button's text is completely gone (probably shifted to low to see) and when I go back to the other button's are visible I get the issue that is shown below. The left is the issue before using the spinner, and the right is the issue. I don't know if it is just the spinner that causes this.
推荐答案
我认为在 RelativeLayout
中使用 Spinner
时出现错误.如果您尝试将根布局更改为 LinearLayout
,则会看到它按预期工作.
I think there is a bug when using Spinner
s inside RelativeLayout
. If you try to change your root layout to a LinearLayout
you2ll see it works as expected.
更改原始布局:
- 根目录布局更改为LinearLayout.
- 在
TableLayout
之间添加了一个虚拟视图,以将它们分开底部.
- root layout changed to LinearLayout.
- a dummy view added between
TableLayout
s to seperate them top and bottom.
Note: I found your question while trying to solve this. Seems similar.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout android:id="@+id/testpracHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- android:background="#ff0000"-->
<TableRow>
<Spinner android:id="@+id/testprac_menu"
android:layout_width="200px"
android:layout_height="wrap_content"></Spinner>
<View android:id="@+id/header_space_buffer"
android:layout_width="40px"
android:layout_height="30px"
android:gravity="center"></View>
<Button android:text="New"
android:id="@+id/newInterval"
android:layout_width="80px"
android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TableLayout android:id="@+id/bottomStruct"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<Button android:layout_width="80px"
android:text="Replay"
android:id="@+id/replay"
android:layout_height="wrap_content"></Button>
<Button android:id="@+id/playInterval"
android:text="Play"
android:layout_width="160px"
android:layout_height="wrap_content"></Button>
<Button android:text="Submit"
android:id="@+id/submit"
android:layout_width="80px"
android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
这篇关于按钮文字移位的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!