自定义操作栏留下左侧的Android黑色空间?(Custom action bar leaves b

2019-10-29 21:33发布

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

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代码

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

截图

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

需要做,以实现这一目标是什么。

Answer 1:

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

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



文章来源: Custom action bar leaves black space on the left android?