Thursday 15 March 2012

android - appcompat-v7: Custom view not properly aligned in ActionBar -



android - appcompat-v7: Custom view not properly aligned in ActionBar -

i trying utilize appcompat toolbar based actionbar

here toolbar.xml

<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="bottom" android:paddingbottom="0dp" android:background="?attr/colorprimarydark"> </android.support.v7.widget.toolbar>

i including in activity.xml file. , in activity's oncreate method, setting custom pagerstrip actionbar

actionbar actionbar = getsupportactionbar(); actionbar.setcustomview(r.layout.pager_strip); actionbar.setdisplayshowcustomenabled(true); tabs = (pagerslidingtabstrip) actionbar.getcustomview().findviewbyid(r.id.tabs_strip); tabs.setviewpager(mpager);

there padding below pagerstrip in actionbar. want remove padding. here image showing issue.

this working fine actionbarsherlock

i had similar problem: have migrated toolbar pattern:

<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary" app:theme="@style/themeoverlay.appcompat.actionbar"> <my.custom.widget.class android:id="@+id/tab_bar" android:layout_width="match_parent" android:layout_height="match_parent"> </my.custom.widget.class> </android.support.v7.widget.toolbar>

but appcompat gave me unusual padding around custom view:

my fix:

add app:contentinsetstart="0dp" , app:contentinsetend="0dp" toolbar attributes; , android:minheight="?attr/actionbarsize" custom widget attributes.

result:

not sure solution follows material design guidelines, hope help someone.

android android-activity appcompat

No comments:

Post a Comment