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

[MaterialButton] maxLines does not work with 99% of inputType

Offen
#4,262 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug Widget: Button
Vorherrschende Sprache
Java
Sterne
17.4k
Forks
3.2k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**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).

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das Problem mit dem bereitgestellten MaterialButton-XML unter Android API 21+ zu reproduzieren, und vergleiche XML android:maxLines="10" mit btn.setMaxLines(10). Verfolge, wie MaterialButton inputType und maxLines während der XML-Inflation verarbeitet. Als erledigt gilt die Aufgabe, wenn mehrzeiliger Text dargestellt wird, während textCapSentences und andere inputType-Formatierungen weiterhin funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.