material-components / material-components/material-components-android

[TextInputLayout] Hint Expanded Gravity

Open
#1,874 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request Widget: TextField
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem?**
The problem is that the hint gravity is always vertical centred. I've managed to centre the `TextInputEditText` text to bottom with styles, but I cannot achieve the same for the hint.

The problem is by the designs of the app I'm developing, the hing and the text are closer to the bottom `boxStroke` of filled Text Input with transparent background.

As you can see the attached images, the space between the bottom line and the hint in the second field is not as desired.

**Describe the solution you'd like**
I'd like to be able to set the expanded hint gravity to bottom from xml, styles or/and programmatically.

**Describe alternatives you've considered**
I've tried to use reflection to call `setExpandedTextGravity`, but it's not working. I can only change the collapsed gravity with reflection. I think that reflection will also not work in newer android versions.

**Additional context**

This is what I'm trying to achieve:
![image](https://user-images.githubusercontent.com/1885042/99189233-e65f0100-2768-11eb-8431-1637cf614893.png)

This is what I've managed to create:
![image](https://user-images.githubusercontent.com/1885042/99189174-b283db80-2768-11eb-91ef-44c616d8a2db.png)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from TextInputLayout and its existing expanded and collapsed hint-gravity behavior, then trace how gravity can be configured through XML, styles, or programmatic APIs. Done means the expanded hint can be aligned to the bottom consistently for the filled Text Input configuration described, without relying on reflection.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.