Android:微调文本向右对齐但不居中 [英] Android: Spinner text alignment to the right but not centered
问题描述
我完成了我的应用程序的英文版本,现在我正在处理阿拉伯语本地化.阿拉伯语是一种从右到左的语言,所以我需要在布局中调整很多东西,包括我的微调显示.
I finished the English version of my application and now I am working on the Arabic localization. Arabic is a right-to-left language, so I need to adjust a lot of things in my layout, including my spinner display.
我使用了此处提到的相同方法 Android -文本在 Spinner 中被推向左侧,但我将重力设置为右侧.
I used the same approach mentioned here Android - Text is Pushed to the Left in a Spinner but I set the gravity to right.
这是我的 spinner_item.xml
Here is my spinner_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_width="fill_parent"
android:gravity="right" />
从
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
到这里
adapter.setDropDownViewResource(R.layout.spinner_item);
我希望我的微调器看起来像我在下面找到的旧英文微调器,
I want my spinner to look like my old English spinner found below,
但目前看起来像这样,
如何恢复以下内容:
- 单选按钮
- 更大的文字尺寸
- 我希望它如图所示位于右侧,但位于两个分隔线之间.
注意阿拉伯语网络服务尚未完成,这就是图像中的数据仍为英文的原因.
NOTE The Arabic webservices aren't finished yet, that's why the data in the image is still in English.
更新
在尝试了 Adil Soomro 的建议后,我得到了以下信息,
After trying Adil Soomro's suggestion, I get the following,
没有单选按钮,边框和第一个字母之间有相当大的空间.
There is no radiobutton and there is a considerable space between the border and the first letter.
更新
经过 Adil Soomro 的编辑,我现在有了以下内容,
After Adil Soomro's edit, I now have the following,
推荐答案
你必须使用CheckedTextView
,它会解决你所有的3个问题.
You have to use CheckedTextView
, it will solve your all 3 problems.
您将放置一个布局 xml,如下所示:
You will place a layout xml something like this:
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:drawableLeft="?android:attr/listChoiceIndicatorSingle"
android:gravity="right|center_vertical"
android:singleLine="true"
android:layout_width="fill_parent"
android:textSize="20dp"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="marquee" />
这篇关于Android:微调文本向右对齐但不居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!