简体   繁体   English

Android Custom EditText文本对齐方式底部

[英]Android Custom EditText text alignment bottom

I created a custom drawable for the background of an EditText. 我为EditText的背景创建了一个自定义绘图。 I need the text to be left and bottom aligned. 我需要将文本左下对齐。 It renders fine on screen but the text is not aligned to the right nor the bottom of the drawable. 它在屏幕上呈现良好的效果,但文本未在可绘制对象的右侧或底部对齐。 I also tried gravity:bottom and tried setting the padding on top in hopes it would move it down. 我还尝试了gravity:bottom,并尝试将padding设置在顶部,希望它将其向下移动。 Is there anything else I can do? 我还能做些什么吗?

在此处输入图片说明

The right and bottom lines define the content area. 右行和底行定义了内容区域。

The line you draw on the right spans the top half of your image. 您在右侧绘制的线跨越了图像的上半部分。 That's why the text won't align to the bottom. 这就是为什么文本不与底部对齐的原因。

You should draw a slightly longer line. 您应该画一条稍长的线。

Check out the image used by default. 签出默认使用的图像。 (I changed it to blue here though). (不过我在这里将其更改为蓝色)。

在此处输入图片说明

This will give the same result you are having. 这将产生与您相同的结果。 The text won't be aligned to the bottom. 文本将不会与底部对齐。

Now if I extend the right line to the bottom, I would obtain the below image. 现在,如果将右线延伸到底部,我将获得以下图像。

在此处输入图片说明

This will give you the expected result. 这将给您预期的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM