摆脱动作栏下的空白区域?
我读了一条线程(尤其是问题)关于Actionbar的高度,但似乎没有人已经得到这个问题: 我的Actionbar本身下面有一个无法解码的空白(BG颜色)区域:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityValveassemblyBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
mContentView = binding.fullscreenContent;
mContentView.getWindowInsetsController().setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
mContentView.getWindowInsetsController().hide(WindowInsets.Type.navigationBars()); // HIDE ANDROID UI
// ACTIONBAR
ActionBar actionBar = getSupportActionBar(); // define actionBar
assert actionBar != null;
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); // allow custom
actionBar.setCustomView(R.layout.actionbar_layout); // define custom
<item name="actionBarSize">48dp</item>
<item name="android:windowActionBarOverlay">true</item>
windowActionBaroverlay = false是相同的结果。
我找不到该区域的名称是什么,或如何删除它。我不能使用这8个像素,直到现在我只有白色的BG活动,但是我必须使用灰色背景,这条线使我很难困扰。
编辑:而且,根据布局检查员的说法,该区域是……什么都没有。
edit2:使用默认的actionbar和空活动:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="38dp"
android:orientation="horizontal"
android:id="@+id/actionbarlinearlayout">
<ImageButton
android:id="@+id/TopLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/settings"
android:src="@drawable/ic_back"
android:background="#00000000"
android:onClick="topLeftButton"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="50dp"
android:contentDescription="@string/shift"
android:src="@drawable/ic_shift" />
<TextView
android:id="@+id/Shift"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginStart="70dp"
android:layout_marginTop="-17dp"
android:fontFamily="@font/fontnats"
android:text="@string/Morningshift"
android:textColor="@color/black"
android:textSize="30sp"
/>
<ImageButton
android:id="@+id/ShiftReload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="172dp"
android:background="#00FFFFFF"
android:onClick="shiftReload"
android:padding="5.5dp"
android:src="@drawable/ic_reload" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_logo_bic" />
I read a half-dozen of threads(particularly this one, who share the issue) about actionBar height, but it seems to no one already get this issue :
My actionBar has an unmodifiable blank(bg color) area under itself :
The custom action bar is defined like this :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityValveassemblyBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
mContentView = binding.fullscreenContent;
mContentView.getWindowInsetsController().setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
mContentView.getWindowInsetsController().hide(WindowInsets.Type.navigationBars()); // HIDE ANDROID UI
// ACTIONBAR
ActionBar actionBar = getSupportActionBar(); // define actionBar
assert actionBar != null;
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); // allow custom
actionBar.setCustomView(R.layout.actionbar_layout); // define custom
As screen said,
<item name="actionBarSize">48dp</item>
<item name="android:windowActionBarOverlay">true</item>
is defined. windowActionBarOverlay = false is the same result.
I can't find what is this area's name, or how to delete it. I can't use these 8 pixels, and until now I only had white bg activites, but I have to use grey background and this line is bothering me so hard.
Edit : and, according to the Layout inspector, this area is... nothing.
Edit2 : with default actionBar and Empty activity :
Edit3 : Add customAction bar layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="38dp"
android:orientation="horizontal"
android:id="@+id/actionbarlinearlayout">
<ImageButton
android:id="@+id/TopLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/settings"
android:src="@drawable/ic_back"
android:background="#00000000"
android:onClick="topLeftButton"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="50dp"
android:contentDescription="@string/shift"
android:src="@drawable/ic_shift" />
<TextView
android:id="@+id/Shift"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginStart="70dp"
android:layout_marginTop="-17dp"
android:fontFamily="@font/fontnats"
android:text="@string/Morningshift"
android:textColor="@color/black"
android:textSize="30sp"
/>
<ImageButton
android:id="@+id/ShiftReload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="172dp"
android:background="#00FFFFFF"
android:onClick="shiftReload"
android:padding="5.5dp"
android:src="@drawable/ic_reload" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_gravity="center"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_logo_bic" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论