Difference between ActionBarSherlock and ActionBar Compatibility

ActionBarSherlock vs ActionBarCompat: I Just want to put few code difference between ActionBarSherlock vs ActionBarCompat Lib We can migrate some apps from ActionBarSherlock to ActionBarCompat: steps: Import AppCompat project. Replace SherlockFragmentActivity with ActionBarActivity. Replace SherlockFragment with Fragment. Change Menu, MenuItem and getSupportMenuInflater() references. Modify the way you get Action Views. mSearchView = (SearchView)MenuItemCompat.getActionView(mSearchItem) Modify your … Read more

Android: remove left margin from actionbar’s custom layout

If you are adding the Toolbar via XML, you can simply add XML attributes to remove content insets. <android.support.v7.widget.Toolbar xmlns:app=”schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”@color/primaryColor” android:contentInsetLeft=”0dp” android:contentInsetStart=”0dp” app:contentInsetLeft=”0dp” app:contentInsetStart=”0dp” android:contentInsetRight=”0dp” android:contentInsetEnd=”0dp” app:contentInsetRight=”0dp” app:contentInsetEnd=”0dp” />

Can’t Find Theme.AppCompat.Light for New Android ActionBar Support

You need to do next: File->Import (android-sdk\extras\android\support\v7). Choose “AppCompat” Project-> properties->Android. In the section library “Add” and choose “AppCompat” That is all! Note: if you are using “android:showAsAction” in menu item, you need to change prefix android as in the example http://developer.android.com/guide/topics/ui/actionbar.html

Display Back Arrow on Toolbar

If you are using an ActionBarActivity then you can tell Android to use the Toolbar as the ActionBar like so: Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar); And then calls to getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); will work. You can also use that in Fragments that are attached to ActionBarActivities you can use it like this: ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); ((ActionBarActivity) … Read more