自定义操作栏中留下左边的Andr​​oid黑色空间?自定义、栏中、黑色、操作

2023-09-12 03:25:55 作者:且将心事兑入酒

我创建了一个自定义的操作栏

I have created a custom action bar

XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="Choose"
    android:textColor="#000000"
    android:id="@+id/mytext"
    android:textSize="18sp" />
 </LinearLayout>

在Java code

The java code

 android.support.v7.app.ActionBar bar = getSupportActionBar();
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    bar.setCustomView(R.layout.action_layout);

截图

正如你可以看到它留下了黑色的商场空间,在屏幕的左上角。我不希望它。我希望它是纯白色。

As you can see it leaves a mall black space to the top left of the screen. I don't want it. I want it to be pure white.

需要做什么来实现这一点。

What needs to be done to achieve this.

推荐答案

尝试调用setDisplayShowHomeEnabled()以虚假的。

Try to call setDisplayShowHomeEnabled() with false.

http://developer.android.com/reference/android/app/ActionBar.html#setDisplayShowHomeEnabled%28boolean%29