Skip to content

Use Material progress bars on Android - #4919

Merged
freakboy3742 merged 10 commits into
beeware:mainfrom
kattni:android-material-progressbar
Dec 3, 2026
Merged

freakboy3742 merged 10 commits into
beeware:mainfrom
kattni:android-material-progressbar

Conversation

@kattni

@kattni kattni commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2250.

On Android, ProgressBar is now a Material LinearProgressIndicator, so it follows the app's Material 3 theme.

  • The native bar always has the same height, whatever size the layout gives it, so it's now a ContainedWidget, centered vertically in the space the layout gives the widget. The probe reports the container's height.
  • The error for a missing Material library is now in the Widget base class, and Button and OptionContainer use it too, so there's only one place to update when the dependency changes.

Verified with the full Android testbed on an API 31 emulator (beePhone): 514 passed, 99 skipped, 56 xfailed, 6 xpassed, with 100.0% coverage.

PR Checklist:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

Assisted-by: Claude Code (Claude Opus 5.5)

Android buttons are now MaterialButtons, so they follow the app's
Material theme. Background colours are applied as a tint.

The Android backend now requires the Material library, and warns at
startup when the app uses a Material 2 theme.
The testbed now uses Theme.Material3.DayNight, the theme Toga's Android
backend requires.
Material 3 is now a requirement of the Android backend as a whole, so the
Button docs don't need to repeat it.
The examples, and the Positron FastAPI bootstrap, used the Material 2
Theme.MaterialComponents.Light.DarkActionBar theme. They now use
Theme.Material3.DayNight, as the testbed does.
A Material button has 24dp of padding at each side, so the fixed 68px width
Toga gave icon buttons cut off the right side of the icon. Measure icon
buttons natively, like text buttons, so the size includes the icon and its
padding, and remove the gap Material leaves between an icon and the text,
which put the icon off center.
Android progress bars are now LinearProgressIndicators, so they follow
the app's Material 3 theme. The native progress bar always has the same
height, whatever size the layout gives it, so it's centered vertically
in the space the layout gives the widget.
raise RuntimeError(
"Unable to import LinearProgressIndicator. Ensure that the Material "
"system package (com.google.android.material:material:1.12.0) "
"is listed in your app's dependencies."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this message to the base class, so there's only one place to update when the dependency changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It's now Widget.require_material() in base.py, and Button and OptionContainer use it too. The other open Material PRs will switch to it once this merges.

freakboy3742 and others added 2 commits December 3, 2026 05:34
Button, OptionContainer and ProgressBar each had their own copy of the
message. It's now in the Widget base class, so there's only one place to
update when the dependency changes.

@freakboy3742 freakboy3742 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All makes sense to me, and the refactoring of the Material warning looks like a nice cleanup.

@freakboy3742
freakboy3742 merged commit 384bc0c into beeware:main Dec 3, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants