在 Android 个 App 的 ActionBar 中同时显示应用程序图标和后退箭头
Show both app icon and back arrow in ActionBar in Android App
我在我的项目中使用 AppCompatV7
库,我想知道如何在我的 ActionBar
中同时显示后退箭头和应用程序图标。目前我只能显示单独的后退箭头或应用程序图标,并且不知道如何(以编程方式)显示它们。你可以帮帮我吗?
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle("");
getSupportActionBar().setLogo("R.drawable.YourIcon");
试试这个。
我测试过并且有效。
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(getResources().getDrawable(R.drawable.ic_launcher));
getSupportActionBar().setDisplayUseLogoEnabled(true);
编辑
getSupportActionBar().setTitle("Your Actionbar Title");
我在我的项目中使用 AppCompatV7
库,我想知道如何在我的 ActionBar
中同时显示后退箭头和应用程序图标。目前我只能显示单独的后退箭头或应用程序图标,并且不知道如何(以编程方式)显示它们。你可以帮帮我吗?
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle("");
getSupportActionBar().setLogo("R.drawable.YourIcon");
试试这个。
我测试过并且有效。
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(getResources().getDrawable(R.drawable.ic_launcher));
getSupportActionBar().setDisplayUseLogoEnabled(true);
编辑
getSupportActionBar().setTitle("Your Actionbar Title");