material-components / material-components/material-components-android
[MaterialButton] maxLines does not work with 99% of inputType
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
I want to display a MaterialButton containing a multi line string, formatted as `android:inputType="textCapSentences"`.
The text is not rendered multi line, only single line. Even though `android:maxLines="10"` is set.
This `android:inputType="textMultiLine"` works, but this `android:inputType="textMultiLine|textCapSentences"` will ignore `textCapSentences`. Other inputTypes are ignored as well.
**Expected behavior:**
The text in the button is rendered multi line, while formatting as `textCapSentences`.
**Workaround:**
Set max lines in code.
This `btn.setMaxLines(10)` renders multiline, with `textCapSentences` formatting. But not if `maxLines` only set in XML.
**Source code:**
```xml
```
**Android API version:**
21+
**Material Library version:**
Both versions experience the same behavior.
1.12.0
1.13.0-alpha05
**Device:**
Emulator 30
To help us triage faster, please check to make sure you are using the [latest version](https://github.com/material-components/material-components-android/releases) of the library.
We also happily accept [pull requests](https://github.com/material-components/material-components-android/pulls).
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 reproducing the issue with the provided MaterialButton XML on Android API 21+ and compare XML android:maxLines="10" with btn.setMaxLines(10). Trace how MaterialButton handles inputType and maxLines during XML inflation. Done means multiline text is rendered while textCapSentences and other inputType formatting continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100