Changing the back button

1

I'm looking forward to changing this back button.

HereintheforumIfoundthiscode

<itemname="android:homeAsUpIndicator">@drawable/back</item> <!-- Icone de voltar -->

But it looks like this:

The icon took the entire toolbar and hid the title.

By code logic, this image that is in drawable would appear on all screens with this function. Can you determine a size per code in this image? (I made the image of the arrow in reduced size, but lost the quality) Is it possible to put a drawable for each screen?

    
asked by anonymous 14.02.2018 / 14:58

1 answer

1

Placing the item android:homeAsUpIndicator in the default theme of the application will cause all activities that use this theme (possibly "AppTheme") to use it.

  

"Can you determine a size per code in this image?"

The Android design guide has metrics set in this regard , I do not think possible. More references .

  

"I made the image of the arrow in reduced size, but lost the quality"

I recommend using Android Asset Studio , a great online tool that can generate images in the correct dimensions.

  

"Is it possible to put a drawable for each screen?"

Yes, instead of setting the drawable in the theme, use the setHomeAsUpIndicator ( ) in each activity

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.icone_toolbar); // <--
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    [...]
}
    
14.02.2018 / 23:20