安卓:微调文本对齐方式的权利,但不集中 [英] Android: Spinner text alignment to the right but not centered

查看:332
本文介绍了安卓:微调文本对齐方式的权利,但不集中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了我的应用程序的英文版本,现在我工作的阿拉伯语的本地化。阿拉伯语是从右到左的语言,所以我需要在我的布局调整了很多东西,包括我的微调显示器。

我用这里提到的同样的方法<一href="http://stackoverflow.com/questions/5755506/text-is-pushed-to-the-left-in-a-spinner-android">Text被推到左边的微调 - 安卓但我设置重力权

下面是我的spinner_item.xml

 &LT; XML版本=1.0编码=UTF-8&GT?;

&LT; TextView中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_height =机器人:ATTR /列表preferredItemHeight
    机器人:layout_width =FILL_PARENT
    机器人:重力=右/&GT;
 

改变了我的code

  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 

  adapter.setDropDownViewResource(R.layout.spinner_item);
 

我想我的微调看起来像我的旧的英语微调下面发现,

但目前看起来是这样的,

我怎样才能恢复如下:

  1. 的单选按钮
  2. 在更大的字体大小
  3. 我想它的权利如图所示,但两个分频器之间的中央。

请注意阿拉伯语Web服务还没有完成,这就是为什么图像中的数据仍是英文。

更新

在试图阿迪尔·苏姆罗的建议下,我得到了以下的,

没有单选按钮,并有边界与第一个字母之间的相当大的空间。

更新

在阿迪尔·苏姆罗的编辑,我现在有如下,<​​/ P>

解决方案

您必须使用 CheckedTextView ,它会解决你的所有3个问题。

您将放置一个布局XML是这样的:

 &LT; CheckedTextView的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@机器人:ID / text1中
    机器人:drawableLeft =机器人:ATTR / listChoiceIndicatorSingle
    机器人:重力=右| center_vertical
    机器人:单线=真
    机器人:layout_width =FILL_PARENT
    机器人:TEXTSIZE =20dp
    机器人:layout_height =机器人:ATTR /列表preferredItemHeight
    机器人:ellipsize =金字招牌/&GT;
 

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.

I used the same approach mentioned here Text is pushed to the left in a spinner - Android but I set the gravity to right.

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" />

Changed my code from

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

to this

adapter.setDropDownViewResource(R.layout.spinner_item);

I want my spinner to look like my old English spinner found below,

But it currently looks like this,

How can I restore the following:

  1. The radio button
  2. The bigger text size
  3. I want it to the right as shown but centered between the two dividers.

NOTE The Arabic webservices aren't finished yet, that's why the data in the image is still in English.

UPDATE

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.

UPDATE

After Adil Soomro's edit, I now have the following,

解决方案

You have to use CheckedTextView, it will solve your all 3 problems.

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" />

这篇关于安卓:微调文本对齐方式的权利,但不集中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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