gpt4 book ai didi

android - 如何从自定义操作栏的顶部和底部删除边距

转载 作者:行者123 更新时间:2023-11-29 01:28:59 27 4
gpt4 key购买 nike

我正在为我的应用程序使用自定义操作栏。这是代码:

actionBar.setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setIcon(null);
actionBar.setCustomView(mCustomView);
Toolbar parent =(Toolbar) mCustomView.getParent();
parent.setContentInsetsAbsolute(0, 0);

这是这段代码的结果,我有顶部和底部的边距:

enter image description here

如何删除这个边距?

我正在为我的应用程序模板使用 Theme.AppCompat.Light。

最佳答案

建议将Toolbar布局xml放在单独的文件中:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/actionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp" >

然后将其包含在您的 main.xml 中

<include layout="@layout/view_action_bar" />

同时确保:app:contentInsetStart="0dp" 这是您的 magins 的主要问题。

关于android - 如何从自定义操作栏的顶部和底部删除边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32330290/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com