机器人的EditText对齐文本右和标签到左 [英] android edittext align text to right and label to left

查看:208
本文介绍了机器人的EditText对齐文本右和标签到左的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有其中显示在编辑文本的左侧有一个标签名称和输入从右到照耀处留下了一个编辑文本

I want to have an edit text where a label "Name" is displayed on left side of the edit text and the input is enterd from Right to left

如果我设置安卓重力如右图,输入从右到左得到。但是,在这种情况下,由于Android任何给定的标签,即:文字的EditText上也即将右对齐

If i set android:gravity as right , input is getting from right to left. But in this case the label ie whatever given as android:text for the edittext is also coming right aligned.

如果我用安卓提示,并设置机器人:重力出任右,完全不显示的提示

If i used android:hint , and set android:gravity as right, the hint is not displayed at all.

什么是让左输入右标签的选项。

What is the option to get label on left and input on right.

推荐答案

我不知道Android的一切,但我依然在想这是不可能的,你问原因你的方式要设置重力1单的EditText ,针对不同的词不同(的名左右的文字到右的)

I don't know everything about android but still I am thinking this is not possible the way you are asking cause You want to set Gravity in 1 single EditText ,different for Different Words(name to left and text to right)

我的想法得到同样的结果是,

My idea to get the same result is,

1)让你的设计师,让你的屏幕宽度的白色圆角矩形和您所需的高度,一个有橙色边框另一个相同的图像(正如你看到的,而选择任何的EditText)

1) Ask your designer to make you one White Round Corner Rectangle of Screen width and your desired height,and one another same image with Orange border (as you see while selecting any edittext)

2)现在,在XML文件中需要一个<的LinearLayout> ,设置第一个图像作为背景来此布局,并在布局取(对于名称:) 1的TextView和EditText上(输入)和设置的TextView - EditText上的背景颜色为透明,哦,是的给予权重力的EditText你希望

2) Now ,In xml file take one <LinearLayout> ,set that first image as background to this layout and in that layout Take 1 TextView(for Name:) and EditText(to input) and set TextView - EditText background color to Transparent,ohh and yes give right gravity to EditText as you wished

3)写出背景的EditText将一个XML文件的选择和替代默认的橙色,使集中BG透明。(所以没有人会认识到,这是的EditText布局内重点时)

3) Write one xml selector file for EditText background and instead of default orange,make focused bg to transparent.(so no one will recognise that this edittext is inside a layout when focused)

4)和写入的LinearLayout选择XML,并设置集中的背景绘制你的第二个图像。

4) and write selector xml for LinearLayout and set focused background drawable to your second image.

你会在屏幕上看到你想要的东西。

And you will see on screen what you wanted.

注:
如果这是你的客户的设计那么它的确定,如果您的机器拥有那么我不赞成你。
请不要问我写的例子。

Notes: If this is your client's design then Its Ok,If yours own then I am not in favour of you. and please don't ask me to write example.

这篇关于机器人的EditText对齐文本右和标签到左的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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