简体   繁体   中英

How to add padding to hint (label) of material design Outlined text field

I want to add left padding to the top label of the material design outlined text field.

Imagine I wanted to put the label on the middle of the textInput field. is that possible and how?

please check the image below to see what kind of label I'm talking about

在此处输入图像描述

I don't think it is possible to have the hint of a TextView be in the middle, only left or right depending on your language localization.

EDIT: With that said, why not try to add preceding/succeeding blank spaces (spacebar characters) in order to sort of hack the alignment of the hint inside your TextView ?

Eg, if you want your text aligned to the left, add the following to your XML

android:gravity="start"
android:hint="  This is my hint"

Otherwise, of you want your text aligned to the right

android:gravity="end"
android:hint="This is my hint   "

Note: I added three spaces just to emphasize the empty spaces inside the hint, but you can play around with the right amount for you, ofc.

You can add padding to the start/left to the TextInputEditText

android:paddingStart="30dp"
android:paddingLeft="30dp"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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