Center position of logo in Action Bar Android -
i want display logo @ centre of action bar. here's custom layout code:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/actionbarwrapper" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" > <imageview android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo" android:layout_centerinparent="true" android:padding="8dp"/> </relativelayout>
and in oncreate() i'm using as:
getsupportactionbar().setdisplayoptions(actionbar.display_show_custom); getsupportactionbar().setcustomview(r.layout.custom_logo); getsupportactionbar().setbackgrounddrawable(new colordrawable(color.parsecolor("#2a2a2a")));
the issue displays fine in normal fragments , activity shifts little right when used navigation drawer. here images:
what doing wrong? thanks.
try using linear layout , layout_gravity
:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/actionbarwrapper" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <imageview android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo" android:layout_gravity="center" android:padding="8dp"/> </linearlayout>
hope help
Comments
Post a Comment