here is the pic please can any one suggest me how to change the icon colour and title to center to the action bar ...
Asked
Active
Viewed 821 times
0
-
Simply use "android.support.v7.widget.Toolbar" and customize your ActionBar as your like. – shobhan Mar 19 '16 at 10:22
-
http://stackoverflow.com/a/12388200/3790150 – saeed Mar 19 '16 at 10:23
-
You might need to create custom actionbar layout for that and you can add it to actionbar as display custom. – Jay Rathod Mar 19 '16 at 10:25
2 Answers
0
Try this:
change pading if you want.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="@dimen/abc_action_bar_default_height_material">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_edit"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="ABC"
android:gravity="center"
android:layout_weight="1"
android:textColor="@android:color/white"
/>
<ImageView
android:layout_width="wrap_content"
android:paddingRight="10dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_edit"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>

Govinda P
- 3,261
- 5
- 22
- 43
-
-
thank you @Govinda , then how to add a edit text n button in the layout so that user can input its details and submit to the next page .. please suggest me and thank you for the help – Abhishek khatua Mar 22 '16 at 02:04
-
back = (Toolbar) findViewById(R.id.back); setSupportActionBar(back); back.setNavigationIcon(R.drawable.ic_navigate_before_white_24dp); back.invalidate() here is the code i have tried still not working so can u suggest me where is my fault.. – Abhishek khatua Mar 22 '16 at 05:22
0
Try like this.
Create new layout custom_toolbar.xml in your project.
Add below code in above file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imgLeft"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:src="@drawable/ic_events" />
<ImageView
android:id="@+id/imgRight"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="10dp"
android:src="@drawable/ic_action" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Test"
android:textColor="@android:color/white"
android:textSize="25sp" />
</RelativeLayout>
And then add that layout to your toolbar xml file.
<?xml version="1.0" encoding="utf-8"?>
<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:background="@color/ColorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<include layout="@layout/custom_toolbar" />
</android.support.v7.widget.Toolbar>
Hope this will help you.

Jay Rathod
- 11,131
- 6
- 34
- 58