ActionBar 标志向左移动
ActionBar logo move left
我想在actionBar上使用logo而不是homeAsUp来打开drawerLayout,我设法做到了,但是homeAsUp的space似乎还剩下,所以看起来logo有leftMargin。
这是我所做的:
style.xml
<item name="android:logo">@drawable/logo_file</item>
<item name="android:displayOptions">showHome|useLogo</item>
logo_file.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/mylogo"
android:left="-10dp"
</layer-list>
Activity
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayUseLogoEnabled(true);
执行 android:left="-10dp"
并不能解决问题,它只会从徽标左侧移除 10dp。
所以请帮我把标志移到左边。
我倾向于在activity的onCreate方法中做如下操作。
ActionBar ab = getSupportActionBar();
ab.setDisplayUseLogoEnabled(true);
ab.setDisplayShowHomeEnabled(true);
ab.setDisplayShowHomeEnabled(false);
ab.setHomeAsUpIndicator(R.drawable.logo_actionbar); //this is your app logo or whatever youre using
ab.setDisplayHomeAsUpEnabled(true);
只要徽标被正确裁剪,它就会按预期布局,而不必担心填充和偏移,尽管如果您使用的是抽屉 there is a great sample on the android website,它显示了如何设置绘制切换正确
我想在actionBar上使用logo而不是homeAsUp来打开drawerLayout,我设法做到了,但是homeAsUp的space似乎还剩下,所以看起来logo有leftMargin。
这是我所做的:
style.xml
<item name="android:logo">@drawable/logo_file</item>
<item name="android:displayOptions">showHome|useLogo</item>
logo_file.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/mylogo"
android:left="-10dp"
</layer-list>
Activity
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayUseLogoEnabled(true);
执行 android:left="-10dp"
并不能解决问题,它只会从徽标左侧移除 10dp。
所以请帮我把标志移到左边。
我倾向于在activity的onCreate方法中做如下操作。
ActionBar ab = getSupportActionBar();
ab.setDisplayUseLogoEnabled(true);
ab.setDisplayShowHomeEnabled(true);
ab.setDisplayShowHomeEnabled(false);
ab.setHomeAsUpIndicator(R.drawable.logo_actionbar); //this is your app logo or whatever youre using
ab.setDisplayHomeAsUpEnabled(true);
只要徽标被正确裁剪,它就会按预期布局,而不必担心填充和偏移,尽管如果您使用的是抽屉 there is a great sample on the android website,它显示了如何设置绘制切换正确