Adam Varhegyi
Adam Varhegyi

Reputation: 9914

Strange black line under my custom Action Bar

I made my custom Action Bar, but there is an ugly underline in under it.

enter image description here

You can see the black line under my green actionBar.

my Action Bar xml:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="3dp"
    android:layout_marginLeft="4dp"
    android:layout_marginRight="0dp"
    android:layout_marginTop="4dp" >

    <ImageButton
        android:id="@+id/menuToggleBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:adjustViewBounds="false"
        android:background="@null"
        android:scaleType="centerInside"
        android:src="@drawable/menu_btn" />

    <ImageView
        android:id="@+id/loadingIconIv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:src="@drawable/flexilogo" />

    <ImageButton
        android:id="@+id/ImageButton01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="false"
        android:background="@null"
        android:scaleType="centerInside"
        android:src="@drawable/menu_btn"
        android:visibility="invisible" />

</LinearLayout>

<View
    android:id="@+id/view1"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#6ea541" />

And my code::

ActionBar actionBar = getActionBar();
    actionBar.setCustomView(R.layout.action_bar);


    menuToggleBtn = (ImageButton) actionBar.getCustomView().findViewById(
            R.id.menuToggleBtn);
    menuToggleBtn.setOnClickListener(this);

    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

Why is that black line is there ? I would like to get rid of it. Please help if you can.

E D I T:

I tried to add:

<item name="android:windowContentOverlay">@null</item>.

to my app's style, but it does not work :(

Upvotes: 2

Views: 2471

Answers (3)

jadeoti
jadeoti

Reputation: 58

android:layout_height="match_parent" on the LinearLayout tag Should fix it

Upvotes: 3

arne.jans
arne.jans

Reputation: 3856

  1. Use the hierarchyviewer perspective in Eclipse ADT and load your activity into it.
  2. Then select different nodes to show their graphical representation.
  3. Try to find the node that includes the black line.
  4. You can also click the approximated spot on the layout-preview in the lower right to select a node that includes this spot.
  5. Then examine the Layout- and Measurement-properties for the selected nodes and neighbouring (sibling) nodes and their graphics preview by right-clicking the node in the tree-view and pressing the box-icon above the small preview.
  6. If you have found the node containing the black line, look at its layout-properties and fix them
  7. If there isn't a node containg the black line for itself, it would likely be a gap in your layout, with the default-background shining through. Then you would have to presumably fix the layout-properties (layout_height) of your main contentview (the one containing the TextView saying "segedanyaok").

Hint:

if your app's activity isn't shown in bold in the Windows-View of the hierarchy-perspective, you need to include the ViewServer-component in your app's activity to enable introspection with hierarchyviewer: https://github.com/romainguy/ViewServer

If the hierarchyviewer-connection gets in trouble (maybe due to timeouts) and is non-responding giving errors, reset the adb-connection to your device from the ddms-perspective, Devices-view, menu-item "Reset adb".

Another hint:

You don't have to use a custom-view to show your logo in such a style. To have a drawer-appliance with a logo, look at how to include Google's navigation drawer http://developer.android.com/design/patterns/navigation-drawer.html and how to include your logo as the actionbar-up/drawer-icon http://developer.android.com/guide/topics/ui/actionbar.html#Logo.

Upvotes: 0

dgimenes
dgimenes

Reputation: 912

It can be a shadow... take a look at Remove shadow below actionbar

To remove it you have to make a style and use <item name="android:windowContentOverlay">@null</item>.

Upvotes: 3

Related Questions