question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug BottomAppBar in RTL mode

See original GitHub issue

Hello . I noticed a weird bug in BottomAppBar

When the application language is RTL , items inside the BottomAppBar are hidden. (This problem is not present in LTR mode).

I also noticed that this problem is fixed when the app:navigationIcon or app:logo is set up.

I do not need an app:navigationIcon or app:logo, please fix this problem, without setting these two, show the items inside BottomAppBar (in RTL mode) .

kotlin : bottom_app_bar.replaceMenu(R.menu.app_bar)

menu :

<?xml version ="1.0" encoding ="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/bar_menu"
        android:checkable="true"
        android:icon="@drawable/ico_menu_secondary"
        android:orderInCategory="1"
        android:title="@string/str_menu"
        app:showAsAction="always" />

    <item
        android:checkable="false"
        android:enabled="false"
        android:orderInCategory="2"
        android:title=""
        app:showAsAction="always" />

    <item
        android:id="@+id/bar_course"
        android:checkable="true"
        android:icon="@drawable/ico_course_secondary"
        android:orderInCategory="3"
        android:title="@string/str_course"
        app:showAsAction="always" />

    <item
        android:id="@+id/bar_reminder"
        android:checkable="true"
        android:icon="@drawable/ico_reminder_secondary"
        android:orderInCategory="4"
        android:title="@string/str_reminder"
        app:showAsAction="always" />

    <item
        android:id="@+id/bar_task"
        android:checkable="true"
        android:icon="@drawable/ico_task_secondary"
        android:orderInCategory="5"
        android:title="@string/str_task"
        app:showAsAction="always" />
</menu>

layout :

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottom_app_bar"
        style="@style/Widget.MaterialComponents.BottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:backgroundTint="?colorAccent"
        app:buttonGravity="bottom"
        app:fabAlignmentMode="end"
        app:hideOnScroll="true"
        app:menu="@menu/app_bar" />

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
Thomas-Voscommented, Aug 31, 2019

Yes, it appears this is fixed in commit https://github.com/material-components/material-components-android/commit/89026898dca97475751dec5418776ad2bfb3757f. We will still need to wait for a newer release. As a temporary workaround (until there is a new release) you can use the following class instead. It has the new code of that commit included.

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;

import com.google.android.material.bottomappbar.BottomAppBar;

public class BottomAppBarFix extends BottomAppBar {

    public BottomAppBarFix(Context context) {
        super(context);
    }

    public BottomAppBarFix(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public BottomAppBarFix(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected int getActionMenuViewTranslationX(ActionMenuView actionMenuView, int fabAlignmentMode, boolean fabAttached) {
        boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
        int toolbarLeftContentEnd = isRtl ? getMeasuredWidth() : 0;

        // Calculate the inner side of the Toolbar's Gravity.START contents.
        for (int i = 0; i < getChildCount(); i++) {
            View view = getChildAt(i);
            boolean isAlignedToStart =
                    view.getLayoutParams() instanceof Toolbar.LayoutParams
                            && (((Toolbar.LayoutParams) view.getLayoutParams()).gravity
                            & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK)
                            == Gravity.START;
            if (isAlignedToStart) {
                toolbarLeftContentEnd =
                        isRtl
                                ? Math.min(toolbarLeftContentEnd, view.getLeft())
                                : Math.max(toolbarLeftContentEnd, view.getRight());
            }
        }

        int end = isRtl ? actionMenuView.getRight() : actionMenuView.getLeft();
        int offset = toolbarLeftContentEnd - end;

        return fabAlignmentMode == FAB_ALIGNMENT_MODE_END && fabAttached ? offset : 0;
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

right-to-left (RTL) in flutter - Stack Overflow
1. force a locale ( and direction ) on all devices · 2. set layout direction according to device locale ( if user...
Read more >
CollapsingToolbarLayout - Android Developers
com.google.android.material.appbar. ... Sets the title collapse mode which determines the effect used to collapse and expand the title text.
Read more >
RTL Languages - MudBlazor - Blazor Component Library
Blazor Component Library based on Material Design. MudBlazor is easy to use and extend, especially for .NET devs because it uses almost no...
Read more >
Right to Left (RTL) in Flutter PDF Viewer (SfPdfViewer)
Learn here all about the Right to Left (RTL) support in Syncfusion Flutter PDF ... context) { return Scaffold( appBar: AppBar( title: const...
Read more >
React UI Roundup
Name, Native Dark Mode, Design Kits, RTL Support, Themer, Native TypeScript ... The API style used for the components contained within the AppBar....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found