1

I designated the image of the Back button as actionBar().setHomeAsUpIndicator(R.mipmap.ic_launcher_foreground);. Can I change the size and location of the specified image?

public class MainActivity extends AppCompatActivity {

    private DrawerLayout mDrawerLayout;
    private Context context = this;

        @Override
        protected void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);

            ActionBar actionBar = getSupportActionBar();
            actionBar.setDisplayShowTitleEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(true); 
            actionBar.setHomeAsUpIndicator(R.mipmap.ic_launcher_foreground);

            mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Choi
  • 11
  • 1
  • Does this answer your question? [How to change toolbar back button icon in android material components](https://stackoverflow.com/questions/62018283/how-to-change-toolbar-back-button-icon-in-android-material-components) – ʍѳђઽ૯ท Feb 04 '21 at 09:06

1 Answers1

0

you can make a specific toolbar instead of action bar with constraint layout and edit it as you want

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
  xmlns:android="https://schemas.android.com/apk/res/android"
  xmlns:app="https://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

 <androidx.appcompat.widget.Toolbar
   android:id="@+id/toolbar"
   android:minHeight="?attr/actionBarSize"  
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   app:titleTextColor="@android:color/white"
   android:background="?attr/colorPrimary">
 </androidx.appcompat.widget.Toolbar>

 <ImageView
  android:id="@+id/simpleImageView"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:src="@drawable/background" />
</android.support.constraint.ConstraintLayout>

style.xml

<resources>
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  </style>
</resources>