Does anybody know how to set padding between the ActionBar's home icon and the title?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Just add
" "
for your app name It will add space between icon and titleI had a similar issue but with spacing between the up and the custom app icon/logo in the action bar. Dushyanth's solution of setting padding programatically worked for me (setting padding on app/logo icon). I tried to find either android.R.id.home or R.id.abs__home (ActionBarSherlock only, as this ensures backwards compatibility), and it seems to work across 2.3-4.3 devices I've tested on.
If you are using toolbar from AppCompat (android.support.v7.widget.Toolbar, >= revision 24, June 2016), the padding between the icon and the title can be changed with the following value :
To improve my answer, you can use it on your toolbar directly inside your activity or you can create a new layout file for your toolbar. In this case, you just have to import your toolbar's @id using the include property on each needed views.
You can then import your layout on your activity.xml
Using
titleMarginStart
works for me. Xamarin example:Set the logo like so:
Im using a custom image instead of the default title text to the right of my apps logo. This is set up programatically like
The issues with the above answers for me are @Cliffus's suggestion does not work for me due to the issues others have outlined in the comments and while @dushyanth programatic padding setting may have worked in the past I would think that the fact that the spacing is now set using
android:layout_marginEnd="8dip"
since API 17 manually setting the padding should have no effect. See the link he posted to git to verify its current state.A simple solution for me is to set a negative margin on my custom view in the actionBar, like so
android:layout_marginLeft="-14dp"
. A quick test shows it works for me on 2.3.3 and 4.3 usingActionBarCompat
Hope this helps someone!
I solved this problem by using custom Navigation layout
Using it you can customize anything in title on action bar:
build.gradle
AndroidManifest.xml
styles.xml
action_bar.xml