How to create semi-transparent circular toolbar / actionbar items?












0















How would you make the items in the toolbar / actionbar with a semi-transparent circular background as seen in the latest Google Maps app (Screenshot)



enter image description here



would you add it to the item-icon itself (XML-Drawable preferred)? would you use the normal menu-xml to create it? I want to use it with a CollapsingToolbarLayout and hide the circular background when the toolbar is collapsed.



Thankful for any thoughts and tips on how to make this :)










share|improve this question



























    0















    How would you make the items in the toolbar / actionbar with a semi-transparent circular background as seen in the latest Google Maps app (Screenshot)



    enter image description here



    would you add it to the item-icon itself (XML-Drawable preferred)? would you use the normal menu-xml to create it? I want to use it with a CollapsingToolbarLayout and hide the circular background when the toolbar is collapsed.



    Thankful for any thoughts and tips on how to make this :)










    share|improve this question

























      0












      0








      0








      How would you make the items in the toolbar / actionbar with a semi-transparent circular background as seen in the latest Google Maps app (Screenshot)



      enter image description here



      would you add it to the item-icon itself (XML-Drawable preferred)? would you use the normal menu-xml to create it? I want to use it with a CollapsingToolbarLayout and hide the circular background when the toolbar is collapsed.



      Thankful for any thoughts and tips on how to make this :)










      share|improve this question














      How would you make the items in the toolbar / actionbar with a semi-transparent circular background as seen in the latest Google Maps app (Screenshot)



      enter image description here



      would you add it to the item-icon itself (XML-Drawable preferred)? would you use the normal menu-xml to create it? I want to use it with a CollapsingToolbarLayout and hide the circular background when the toolbar is collapsed.



      Thankful for any thoughts and tips on how to make this :)







      android android-actionbar material-design android-collapsingtoolbarlayout






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 15:08









      f4bf4b

      303148




      303148
























          1 Answer
          1






          active

          oldest

          votes


















          0














          add imageView to CollapsingToolbarLayout and use app:layout_collapseMode="parallax"



          example:



          <android.support.design.widget.AppBarLayout
          android:layout_height="200dp"
          android:layout_width="match_parent"
          android:theme="@style/AppTheme.AppBarOverlay">

          <android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleMarginEnd="64dp"
          app:expandedTitleMarginStart="48dp"
          app:layout_scrollFlags="scroll|exitUntilCollapsed">

          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          app:layout_scrollFlags="scroll|enterAlways" />
          <ImageView
          android:src="@drawable/cheese_1"
          app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:scaleType="centerCrop"
          app:layout_collapseMode="parallax"
          android:minHeight="100dp" />

          </android.support.design.widget.CollapsingToolbarLayout>
          </android.support.design.widget.AppBarLayout>


          in code use OnOffsetChangedListener to listen to the state of appbar expand/collapse and you can change toolbar icon items



            final AppBarLayout mAppBarLayout = findViewById(R.id.appbar);
          mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
          private State state;

          @Override
          public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
          if (verticalOffset == 0) {
          if (state != State.EXPANDED) {
          //change item rounded icon
          }
          state = State.EXPANDED;

          } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
          if (state != State.COLLAPSED) {
          //change item default icon
          }
          state = State.COLLAPSED;
          } else {
          if (state != State.IDLE) {
          Log.d(TAG,"Idle");
          }
          state = State.IDLE;
          }
          }
          });





          share|improve this answer


























          • but what about the default backbutton and overflow menu?

            – f4b
            Jan 3 at 10:09











          • i updated my answer

            – Amrdroid
            Jan 3 at 11:07











          • well, i know how to use onOffsetChanged. Does that mean you would implement a custom overflow menu and backbutton?

            – f4b
            Jan 3 at 14:44











          • you not need to create a custom, you can change the default icon of this items

            – Amrdroid
            Jan 3 at 14:57











          • how would i change the default overflow menu and backbutton? is there a way that's not too hacky?

            – f4b
            Jan 7 at 7:54











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008678%2fhow-to-create-semi-transparent-circular-toolbar-actionbar-items%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          add imageView to CollapsingToolbarLayout and use app:layout_collapseMode="parallax"



          example:



          <android.support.design.widget.AppBarLayout
          android:layout_height="200dp"
          android:layout_width="match_parent"
          android:theme="@style/AppTheme.AppBarOverlay">

          <android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleMarginEnd="64dp"
          app:expandedTitleMarginStart="48dp"
          app:layout_scrollFlags="scroll|exitUntilCollapsed">

          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          app:layout_scrollFlags="scroll|enterAlways" />
          <ImageView
          android:src="@drawable/cheese_1"
          app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:scaleType="centerCrop"
          app:layout_collapseMode="parallax"
          android:minHeight="100dp" />

          </android.support.design.widget.CollapsingToolbarLayout>
          </android.support.design.widget.AppBarLayout>


          in code use OnOffsetChangedListener to listen to the state of appbar expand/collapse and you can change toolbar icon items



            final AppBarLayout mAppBarLayout = findViewById(R.id.appbar);
          mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
          private State state;

          @Override
          public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
          if (verticalOffset == 0) {
          if (state != State.EXPANDED) {
          //change item rounded icon
          }
          state = State.EXPANDED;

          } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
          if (state != State.COLLAPSED) {
          //change item default icon
          }
          state = State.COLLAPSED;
          } else {
          if (state != State.IDLE) {
          Log.d(TAG,"Idle");
          }
          state = State.IDLE;
          }
          }
          });





          share|improve this answer


























          • but what about the default backbutton and overflow menu?

            – f4b
            Jan 3 at 10:09











          • i updated my answer

            – Amrdroid
            Jan 3 at 11:07











          • well, i know how to use onOffsetChanged. Does that mean you would implement a custom overflow menu and backbutton?

            – f4b
            Jan 3 at 14:44











          • you not need to create a custom, you can change the default icon of this items

            – Amrdroid
            Jan 3 at 14:57











          • how would i change the default overflow menu and backbutton? is there a way that's not too hacky?

            – f4b
            Jan 7 at 7:54
















          0














          add imageView to CollapsingToolbarLayout and use app:layout_collapseMode="parallax"



          example:



          <android.support.design.widget.AppBarLayout
          android:layout_height="200dp"
          android:layout_width="match_parent"
          android:theme="@style/AppTheme.AppBarOverlay">

          <android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleMarginEnd="64dp"
          app:expandedTitleMarginStart="48dp"
          app:layout_scrollFlags="scroll|exitUntilCollapsed">

          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          app:layout_scrollFlags="scroll|enterAlways" />
          <ImageView
          android:src="@drawable/cheese_1"
          app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:scaleType="centerCrop"
          app:layout_collapseMode="parallax"
          android:minHeight="100dp" />

          </android.support.design.widget.CollapsingToolbarLayout>
          </android.support.design.widget.AppBarLayout>


          in code use OnOffsetChangedListener to listen to the state of appbar expand/collapse and you can change toolbar icon items



            final AppBarLayout mAppBarLayout = findViewById(R.id.appbar);
          mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
          private State state;

          @Override
          public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
          if (verticalOffset == 0) {
          if (state != State.EXPANDED) {
          //change item rounded icon
          }
          state = State.EXPANDED;

          } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
          if (state != State.COLLAPSED) {
          //change item default icon
          }
          state = State.COLLAPSED;
          } else {
          if (state != State.IDLE) {
          Log.d(TAG,"Idle");
          }
          state = State.IDLE;
          }
          }
          });





          share|improve this answer


























          • but what about the default backbutton and overflow menu?

            – f4b
            Jan 3 at 10:09











          • i updated my answer

            – Amrdroid
            Jan 3 at 11:07











          • well, i know how to use onOffsetChanged. Does that mean you would implement a custom overflow menu and backbutton?

            – f4b
            Jan 3 at 14:44











          • you not need to create a custom, you can change the default icon of this items

            – Amrdroid
            Jan 3 at 14:57











          • how would i change the default overflow menu and backbutton? is there a way that's not too hacky?

            – f4b
            Jan 7 at 7:54














          0












          0








          0







          add imageView to CollapsingToolbarLayout and use app:layout_collapseMode="parallax"



          example:



          <android.support.design.widget.AppBarLayout
          android:layout_height="200dp"
          android:layout_width="match_parent"
          android:theme="@style/AppTheme.AppBarOverlay">

          <android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleMarginEnd="64dp"
          app:expandedTitleMarginStart="48dp"
          app:layout_scrollFlags="scroll|exitUntilCollapsed">

          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          app:layout_scrollFlags="scroll|enterAlways" />
          <ImageView
          android:src="@drawable/cheese_1"
          app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:scaleType="centerCrop"
          app:layout_collapseMode="parallax"
          android:minHeight="100dp" />

          </android.support.design.widget.CollapsingToolbarLayout>
          </android.support.design.widget.AppBarLayout>


          in code use OnOffsetChangedListener to listen to the state of appbar expand/collapse and you can change toolbar icon items



            final AppBarLayout mAppBarLayout = findViewById(R.id.appbar);
          mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
          private State state;

          @Override
          public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
          if (verticalOffset == 0) {
          if (state != State.EXPANDED) {
          //change item rounded icon
          }
          state = State.EXPANDED;

          } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
          if (state != State.COLLAPSED) {
          //change item default icon
          }
          state = State.COLLAPSED;
          } else {
          if (state != State.IDLE) {
          Log.d(TAG,"Idle");
          }
          state = State.IDLE;
          }
          }
          });





          share|improve this answer















          add imageView to CollapsingToolbarLayout and use app:layout_collapseMode="parallax"



          example:



          <android.support.design.widget.AppBarLayout
          android:layout_height="200dp"
          android:layout_width="match_parent"
          android:theme="@style/AppTheme.AppBarOverlay">

          <android.support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleMarginEnd="64dp"
          app:expandedTitleMarginStart="48dp"
          app:layout_scrollFlags="scroll|exitUntilCollapsed">

          <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          app:layout_scrollFlags="scroll|enterAlways" />
          <ImageView
          android:src="@drawable/cheese_1"
          app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:scaleType="centerCrop"
          app:layout_collapseMode="parallax"
          android:minHeight="100dp" />

          </android.support.design.widget.CollapsingToolbarLayout>
          </android.support.design.widget.AppBarLayout>


          in code use OnOffsetChangedListener to listen to the state of appbar expand/collapse and you can change toolbar icon items



            final AppBarLayout mAppBarLayout = findViewById(R.id.appbar);
          mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
          private State state;

          @Override
          public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
          if (verticalOffset == 0) {
          if (state != State.EXPANDED) {
          //change item rounded icon
          }
          state = State.EXPANDED;

          } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
          if (state != State.COLLAPSED) {
          //change item default icon
          }
          state = State.COLLAPSED;
          } else {
          if (state != State.IDLE) {
          Log.d(TAG,"Idle");
          }
          state = State.IDLE;
          }
          }
          });






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 11:06

























          answered Jan 2 at 15:35









          AmrdroidAmrdroid

          318110




          318110













          • but what about the default backbutton and overflow menu?

            – f4b
            Jan 3 at 10:09











          • i updated my answer

            – Amrdroid
            Jan 3 at 11:07











          • well, i know how to use onOffsetChanged. Does that mean you would implement a custom overflow menu and backbutton?

            – f4b
            Jan 3 at 14:44











          • you not need to create a custom, you can change the default icon of this items

            – Amrdroid
            Jan 3 at 14:57











          • how would i change the default overflow menu and backbutton? is there a way that's not too hacky?

            – f4b
            Jan 7 at 7:54



















          • but what about the default backbutton and overflow menu?

            – f4b
            Jan 3 at 10:09











          • i updated my answer

            – Amrdroid
            Jan 3 at 11:07











          • well, i know how to use onOffsetChanged. Does that mean you would implement a custom overflow menu and backbutton?

            – f4b
            Jan 3 at 14:44











          • you not need to create a custom, you can change the default icon of this items

            – Amrdroid
            Jan 3 at 14:57











          • how would i change the default overflow menu and backbutton? is there a way that's not too hacky?

            – f4b
            Jan 7 at 7:54

















          but what about the default backbutton and overflow menu?

          – f4b
          Jan 3 at 10:09





          but what about the default backbutton and overflow menu?

          – f4b
          Jan 3 at 10:09













          i updated my answer

          – Amrdroid
          Jan 3 at 11:07





          i updated my answer

          – Amrdroid
          Jan 3 at 11:07













          well, i know how to use onOffsetChanged. Does that mean you would implement a custom overflow menu and backbutton?

          – f4b
          Jan 3 at 14:44





          well, i know how to use onOffsetChanged. Does that mean you would implement a custom overflow menu and backbutton?

          – f4b
          Jan 3 at 14:44













          you not need to create a custom, you can change the default icon of this items

          – Amrdroid
          Jan 3 at 14:57





          you not need to create a custom, you can change the default icon of this items

          – Amrdroid
          Jan 3 at 14:57













          how would i change the default overflow menu and backbutton? is there a way that's not too hacky?

          – f4b
          Jan 7 at 7:54





          how would i change the default overflow menu and backbutton? is there a way that's not too hacky?

          – f4b
          Jan 7 at 7:54




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008678%2fhow-to-create-semi-transparent-circular-toolbar-actionbar-items%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          Npm cannot find a required file even through it is in the searched directory