material-components / material-components/material-components-android
[TextInputLayout] Setting end icon gravity
Nobody has claimed this yet.
- 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.**
In a multi line TextInputEditText the end icon is always centered, but in some cases we need it to be set to top or at the bottom of the layout.

After some internet research I didn't find any suitable solution. I tried to explore the implementation class TextInputLayout.java and found out that the end icon is place as a drawable in CheckableImageButton (com.google.android.material.R.id.text_input_end_icon) and the button is place in a FrameLayout.
What I did is finding the button by its ID and then customize the layout params.
```java
// using viewbinding
private ActivityCommentBinding mBinding;
// change the end icon gravity
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mBinding.commentTextLayout
.findViewById(com.google.android.material.R.id.text_input_end_icon)
.getLayoutParams();
params.gravity = Gravity.TOP;
mBinding.commentTextLayout
.findViewById(com.google.android.material.R.id.text_input_end_icon)
.setLayoutParams(params);
```
Result:

**Describe the solution you'd like**
I think it would be useful to have a TextInputLayout XML attribute to set the end icon gravity.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading TextInputLayout.java and the CheckableImageButton identified in the issue to understand how the end icon is positioned. Define the public XML attribute and its supported gravity values, then verify that multiline end icons can be aligned at the top or bottom while preserving existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- design, mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100