material-components / material-components/material-components-android
[MaterialAlertDialog] Title panel layout's direction match with RTL title text
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**When the Title text is a RTL-language text the Icon remain in Left side of Title panel while I expect title layout follow the direction of title text. i.e. if text is RTL then Title panel layout direction become RTL as well. i.e. Icon in Right of the Title Text**
**Describe the solution you'd like**
I suggest add an extra attribute "auto" (or "content") for layoutDirection. i.e.
```
```
and check if the first char of Title text is RTL or LTR and set the panel direction accordingly:
```
int direction = getLayoutDirectionFromFirstChar();
String title = getTitle();
private int getLayoutDirectionFromFirstChar() {
switch (Character.getDirectionality(title.charAt(0))) {
case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
return ViewCompat.LAYOUT_DIRECTION_RTL;
case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
default:
return ViewCompat.LAYOUT_DIRECTION_LTR;
}
}
if(attr value ==4) {
getTitlePanel().setLayoutDirection(direction)
}
```
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 locating the MaterialAlertDialog title-panel implementation and its current layoutDirection handling. Review the existing Android RTL behavior and dialog tests before deciding how the proposed attribute fits the public API. Done means RTL title text places the icon on the right, while LTR title text preserves the expected left placement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100