Any idea why the home up button for material design might turn black after being rotated?

I add a fragment to the portrait by turning towards the landscape, then turning back towards the portrait. After the second turn, the button home up

turns black. Any idea what could be causing this?

  • I am using theme Theme.AppCompat.Light.DarkActionBar

    .
  • I am using ActionBar

    for this snippet, but Toolbar

    for the snippet added to the album.
  • If you first add the snippet to the album, then switch to the portrait, it will be black.
  • If I turn the landscape a third time, it turns white and then black again when I return to the portrait.
  • I am using this same Fragment

    in another Activity

    and I do not see this behavior.

Action bar after two rotations

+3


source to share


1 answer


I had the same problem as you. I am using a toolbar in an activity containing a navigation drawer that hosts a number of flags, some of which have lists. When I select an item in the list view, the new information kicks in, in which I use the action bar instead of the tool bar. On rotation, the main up arrow changes to a dark gray color, and on subsequent rotations, the color remains the same and does not change to white, even if I use Theme.AppCompat.Light.DarkActionBar to activate the details.

I solved this problem by adding a toolbar to my part layout and applying a dark home screen theme directly to the toolbar

<android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/details_toolbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/abc_action_bar_default_height_material"
        android:background="@drawable/actionbar_background"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

      

I am not referencing the above toolbar in my activity or snippet and am still using the action bar as before. I don't set the toolbar as an action bar or with setSupportActionBar(mToolbar);

, it is just present in my layout and nothing more, but now when I rotate the device, the up arrow does not change color and remains white as expected. It's weird, but it works.



Edit: I should have mentioned that the placement of the toolbar in my data activity is such that it is not actually visible. Specifying the visibility of the toolbar for invisible workandroid:visibility="invisible"

Edit: I was wondering why this worked and it seemed very strange to me, so I completely removed the toolbar and added the theme to the view group at the root of my layout. This makes more sense.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:id="@+id/details_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    android:orientation="vertical">

      

+3


source







All Articles