更改语言时,我的自定义按钮会截断一些文本
我制作了自己的自定义按钮样式,它们在我的手机上与某些语言配合得非常好。
我为 DK 和 UK 制作了 strings.xml。然而,当我选择法国作为手机语言时,我的按钮在底部被切断。
似乎无法弄清楚为什么要这样做。
有什么想法吗?我试过 HTC Hero、HTC Desire 和 GarminAsus A10,效果都是一样的。
编辑布局:
<?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" android:background="@drawable/bg"
android:padding="0dip">
<LinearLayout android:id="@+id/linearLayout1"
android:orientation="vertical" android:gravity="center"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_marginLeft="40dip" android:layout_marginRight="40dip">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/hintUsername"
android:text="@string/hintUsernameText" style="@style/CodeFont"></TextView>
<EditText android:id="@+id/unameEditText"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:inputType="textPersonName" android:hint="@string/usernameHint">
<requestFocus></requestFocus>
</EditText>
<TextView android:layout_height="wrap_content" android:id="@+id/textView1"
android:layout_width="fill_parent" android:text="@string/hintPasswordText"
style="@style/CodeFont"></TextView>
<EditText android:id="@+id/pwEditText" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:inputType="textPassword"
android:hint="@string/pwHint"></EditText>
<CheckBox android:layout_height="wrap_content" android:id="@+id/rememberLoginCheckbox"
android:text="@string/rememberLoginCheckbox" android:layout_width="fill_parent"
android:gravity="center" style="@style/CodeFont"></CheckBox>
<Button android:id="@+id/loginButton" android:text="@string/logonButton"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:background="@drawable/btn_custom" android:textSize="18dp"></Button>
<TextView android:id="@+id/errorTextView" android:text=""
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:textColor="#FF0000"></TextView>
</LinearLayout>
</LinearLayout>
自定义按钮的背景:
我猜我的 ninepatch 有可能是错误创建的,但在我的手机上选择丹麦语或英语时,它看起来是正确的。
I've made my own custom button styles and they work splendid with some languages on my phones.
I've made strings.xml for DK and UK. However when I chose for instance france as language on my phone my buttons gets cut off in the bottom.
Can't seem to figure out why it does that.
Any ideas? I've tried on a HTC Hero, HTC Desire and a GarminAsus A10, all does the same.
EDIT layout:
<?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" android:background="@drawable/bg"
android:padding="0dip">
<LinearLayout android:id="@+id/linearLayout1"
android:orientation="vertical" android:gravity="center"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_marginLeft="40dip" android:layout_marginRight="40dip">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/hintUsername"
android:text="@string/hintUsernameText" style="@style/CodeFont"></TextView>
<EditText android:id="@+id/unameEditText"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:inputType="textPersonName" android:hint="@string/usernameHint">
<requestFocus></requestFocus>
</EditText>
<TextView android:layout_height="wrap_content" android:id="@+id/textView1"
android:layout_width="fill_parent" android:text="@string/hintPasswordText"
style="@style/CodeFont"></TextView>
<EditText android:id="@+id/pwEditText" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:inputType="textPassword"
android:hint="@string/pwHint"></EditText>
<CheckBox android:layout_height="wrap_content" android:id="@+id/rememberLoginCheckbox"
android:text="@string/rememberLoginCheckbox" android:layout_width="fill_parent"
android:gravity="center" style="@style/CodeFont"></CheckBox>
<Button android:id="@+id/loginButton" android:text="@string/logonButton"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:background="@drawable/btn_custom" android:textSize="18dp"></Button>
<TextView android:id="@+id/errorTextView" android:text=""
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:textColor="#FF0000"></TextView>
</LinearLayout>
</LinearLayout>
Background for custom button:
I guess there is a possibility that my ninepatch is wrongly created, but it looks right when chosing danish or english language on my phones.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以我自己解决了这个问题。
在浏览完 styles.xml 文件后,我发现我已将按钮的高度固定为 25dip。当我的手机使用丹麦语或英语时,这看起来是正确的,但是当将其更改为任何其他语言时,按钮文本被切断,如我上一篇文章中的图片所示。
所以答案是删除 styles.xml 文件中的高度,并将高度设置为wrapp_content。
我不知道这是否是 Android api 中的错误,但我将报告它并看看会发生什么。真的很奇怪,这两种语言不会发生这种情况,但对于其他所有语言都不会发生 - 我什至尝试为另一种语言添加值文件夹,并从使用的默认值文件夹中添加相同的文件,但这没有帮助。
在互联网上盲目地学习教程就这么多了:P
Ok, so I've solved this myself.
After going through my styles.xml file I found out that I had fixated the height of the buttons by 25dip. This looked right when my phones was using Danish or English language, but when changing it to any other language the button text was cut off, as shown on the picture in my previous post.
So the answer is to remove the height inside the styles.xml file and just set the height to wrap_content.
I don't know if this is a bug in the Android api, but I am going to report it and see what happens. It's really odd that it doesn't happen for those two languages but for every other language - I even tried to add a values folder for another language and added the same files from the default values folder that was used, but it didn't help.
So much for following tutorials blindly on the interwebs :P