Here i am going to show you how to create custom action bar in all the screen.
My XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/menu_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/abplain" >
<TextView
android:id="@+id/login_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fontFamily="Arial"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:text="Custom Action bar"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Color.XML
Add this color.xml in your Values folder
<?xml version="1.0" encoding="utf-8"?>
<resources >
<color name="white">#FFFFFF</color>
<color name="yellow">#FFFF00</color>
<color name="fuchsia">#FF00FF</color>
<color name="red">#FF0000</color>
<color name="silver">#C0C0C0</color>
<color name="gray">#808080</color>
<color name="olive">#808000</color>
<color name="purple">#800080</color>
<color name="maroon">#800000</color>
<color name="aqua">#00FFFF</color>
<color name="lime">#00FF00</color>
<color name="teal">#008080</color>
<color name="green">#008000</color>
<color name="blue">#0000FF</color>
<color name="navy">#000080</color>
<color name="black">#000000</color>
<color name="terrorblue">#33b5e5</color>
<color name="headingblue">#29a2d6</color>
</resources>
My XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/menu_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/abplain" >
<TextView
android:id="@+id/login_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fontFamily="Arial"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:text="Custom Action bar"
android:textColor="@color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Color.XML
Add this color.xml in your Values folder
<?xml version="1.0" encoding="utf-8"?>
<resources >
<color name="white">#FFFFFF</color>
<color name="yellow">#FFFF00</color>
<color name="fuchsia">#FF00FF</color>
<color name="red">#FF0000</color>
<color name="silver">#C0C0C0</color>
<color name="gray">#808080</color>
<color name="olive">#808000</color>
<color name="purple">#800080</color>
<color name="maroon">#800000</color>
<color name="aqua">#00FFFF</color>
<color name="lime">#00FF00</color>
<color name="teal">#008080</color>
<color name="green">#008000</color>
<color name="blue">#0000FF</color>
<color name="navy">#000080</color>
<color name="black">#000000</color>
<color name="terrorblue">#33b5e5</color>
<color name="headingblue">#29a2d6</color>
</resources>
Manifest:
<activity
android:name="com.example.Test.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
No comments:
Post a Comment