Issue
these are my menus :
<item
android:id="@+id/search"
android:icon="@drawable/ic_action_search"
android:orderInCategory="2"
android:title="@string/search"
yourapp:showAsAction="always|withText"/>
<item
android:id="@+id/newadd"
android:icon="@drawable/ic_action_new"
android:orderInCategory="3"
android:title="@string/newadd"
yourapp:showAsAction="always|withText"/>
<item
android:id="@+id/sort"
android:icon="@drawable/ic_action_sort_by_size"
android:orderInCategory="1"
yourapp:showAsAction="always"/>
when I run the app , all 3 of them are on the right side of actionbar , How can I make them to move to left side of actionbar ?
also , I've an navigationDrawer , the icon is on the left side and I want to move it to the right side , How can I do so ?
I don't have any search on my actionbar .
How can I do so ?
thanks
Solution
You can use custom views for actionbar
ActionBar mActionBar = getActionBar();
View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
mActionBar.setCustomView(mCustomView);
mActionBar.setDisplayShowCustomEnabled(true);
actionbar xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_horizontal_margin" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/imageView1"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/imageView2"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
set these methods for actionbar to make navigation drawer home icon visible
getActionBar().setBackgroundDrawable(
new ColorDrawable(Color.parseColor("#56B1D8"))); //$NON-NLS-1$
LayoutInflater inflator = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ActionBar actionBar = getActionBar();
getActionBar().setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
// actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
// getActionBar().setIcon(R.drawable.ic_navigation_drawer);
// navigation icon on actionbar
actionBar.setHomeButtonEnabled(true);
actionBar.setIcon(null);
Answered By - SHASHIDHAR MANCHUKONDA
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.