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

[TextInputLayout] Apply different gravities to `app:prefixText`

Open
#1,895 2 comments 3 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? Please describe.**
As of right now, you can't make a `TextInputLayout` center its content (including the underlying prefix and `TextInputEditText`). You can certainly center the TIET by calling `android:gravity=center` on it, but invoking that on the TIL does...nothing 😂

**Describe the solution you'd like**
The TIL seems to stack the "start" content (prefix, icon) from the `start` side. I think that's a super reasonable default, but having some way to configure a different gravity to the start content (in my specific case, `app:prefixText`) would be super useful.

**Additional context**
This is the screen I'm trying to build:
![image](https://user-images.githubusercontent.com/1294660/100010870-eda49100-2d9e-11eb-90c3-ef50febd4ca7.png)

If I want my content centered _and_ I want to have a prefix, I basically have to roll my own fancy EditText.

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 by locating TextInputLayout's handling of app:prefixText and the interaction with TextInputEditText's android:gravity; the issue names no files or tests. Define how configurable gravity should apply to the prefix and other start content while preserving the current default, then verify that centered content with a prefix works as requested.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.