Custom action bar leaves black space on the left android?

一笑奈何 提交于 2019-12-14 03:14:10

问题


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>

The java code

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

The screenshot

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.


回答1:


Try to call setDisplayShowHomeEnabled() with false.

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



来源:https://stackoverflow.com/questions/27793669/custom-action-bar-leaves-black-space-on-the-left-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!