0

Is it possible to resize the ActionBar menu item?

enter image description here

I added ProgressBar to ActionBar as described here: https://github.com/codepath/android_guides/wiki/Handling-ProgressBars#progress-within-actionbar

Settings:

<?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"
    xmlns:tools="http://schemas.android.com/tools">

    <item
        android:id="@+id/miActionProgress"
        android:title="Loading..."
        android:visible="false"
        android:orderInCategory="100"
        app:showAsAction="always"
        app:actionLayout="@layout/action_view_progress" />

</menu>

ProgressBar:

<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:indeterminateTint="@color/colorProgressWhite"
    android:id="@+id/pbProgressAction" />
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
mindo
  • 472
  • 1
  • 3
  • 10
  • how about setting android:height and width to ? And android_layout of course accordingly – Vitali Pom Mar 08 '18 at 15:52
  • I tried android:height but it has no effect. – mindo Mar 08 '18 at 16:33
  • Please see my answer and the link which has examples on how you should properly do it by using `` android:layout_height="wrap_content"`` – Vitali Pom Mar 08 '18 at 16:35
  • @VitaliPom I checked your comment as well as the example, but I can't make sense of it. Accepted answer included changing from LinearLayout to Frame/Relative one, other answers included weights, and I don't see how any of that is relative. – mindo Mar 08 '18 at 16:52
  • They are relative, since your layout_width defines how will you define your width in your children – Vitali Pom Mar 08 '18 at 17:46

1 Answers1

0

When you set up your android:layout_width="wrap_content" at your parent component, your child receive this property too. That means that all of your components will fit as much as possible, for instance 100% of the parent. (Still as much as they can, it can be 100% of the size they can fill, not the whole component. Here you have 100% of the width of the progress bar which is also 100% of the height, since they are the same and the rest is title, which is 100% for height, but this time not 100% for width.)

Now that setting, which sets the wrap layout for the parent and same wrap parent for the children, can be overwritten by the children (overridden more accurately).

When you set these parameters, your width and height becomes automatically set to Filling. In order to change that, just change the width and the height as in here: Android layout_width & layout_height, how it works?

Vitali Pom
  • 602
  • 1
  • 8
  • 29