0

我一直在阅读有关这一点,并发现它附带的SDK 24,并且已经找到了解决方案,工具栏额外保证金/填充,只需将内容填充:app:contentInsetStartWithNavigation="0dp"更改动作条通过样式

的问题是,我的大多数活动的布局并不主题的“不采取行动吧”,例如:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="package"> 
     <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/listViewContato" /> 
</LinearLayout> 

因此,在这种情况下,到底如何我可以删除多余的保证金/填充?因为这将是恼人的变化的所有活动添加的工具列...

+0

如果你想使'actionBar'定制的,你需要使用工具栏。它也很容易与''一起使用。 – adnbsr

+0

使用工具栏,然后指定其自定义布局。查看Google官方文档:https://developer.android.com/reference/android/widget/Toolbar.html –

回答

0

你可以做到这一点定义自定义样式为您的活动:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    ... 
    <item name="actionBarStyle">@style/MyActionBarStyle</item> 
</style> 

<style name="MyActionBarStyle" parent="Widget.AppCompat.Light.ActionBar.Solid"> 
    <item name="contentInsetStart">0dp</item> 
    <item name="contentInsetEnd">0dp</item> 
    <item name="contentInsetStartWithNavigation">0dp</item> 
</style>