Skip to content

Instantly share code, notes, and snippets.

@omerucel
Last active December 11, 2015 19:08
Show Gist options
  • Save omerucel/4646133 to your computer and use it in GitHub Desktop.
Save omerucel/4646133 to your computer and use it in GitHub Desktop.
Android Toolbar - Screen Shot : http://dl.dropbox.com/u/14113161/screenshot.png
<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">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
style="@style/CustomToolbarContainer">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CustomToolbarWrapper"
android:padding="0dp">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top Stories"
style="@style/CustomToolbarButtonHomepage"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notifications"
style="@style/CustomToolbarButtonNotification" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browse"
style="@style/CustomToolbarButtonBrowse" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
style="@style/CustomToolbarButtonProfile" />
</TableRow>
</TableLayout>
</RelativeLayout>
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true">
<shape android:shape="rectangle">
<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />
<gradient android:type="radial"
android:gradientRadius="60"
android:startColor="#FFF6F6F6"
android:centerColor="#FFE8E8E8"
android:endColor="#FFD9D9D9" />
</shape>
</item>
<item
android:state_focused="false" android:state_pressed="false">
<shape android:shape="rectangle">
<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />
<gradient android:angle="90"
android:type="linear"
android:endColor="#FFF6F6F6"
android:centerColor="#FFE8E8E8"
android:startColor="#FFD9D9D9" />
</shape>
</item>
</selector>
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FF000000"
android:state_pressed="true" />
<item android:color="#AA000000"
android:state_focused="false" android:state_pressed="false" />
</selector>
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true">
<bitmap android:src="@drawable/dashboard_active" />
</item>
<item
android:state_focused="false" android:state_pressed="false">
<bitmap android:src="@drawable/dashboard_passive"/>
</item>
</selector>
package com.example.navigationstyle;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn1 = (Button) findViewById(R.id.button1);
Button btn2 = (Button) findViewById(R.id.button2);
Button btn3 = (Button) findViewById(R.id.button3);
Button btn4 = (Button) findViewById(R.id.button4);
Typeface font = Typeface.createFromAsset(getAssets(),
"fonts/Roboto-Bold.ttf");
btn1.setTypeface(font);
btn2.setTypeface(font);
btn3.setTypeface(font);
btn4.setTypeface(font);
btn1.setPressed(true);
btn1.setClickable(false);
}
@Override
public void onClick(View v) {
}
}
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme">
<item name="android:background">#FFFFFFFF</item>
</style>
<style name="CustomToolbarContainer">
<item name="android:background">#FFAAAAAA</item>
<item name="android:paddingTop">0.5dp</item>
</style>
<style name="CustomToolbarWrapper">
<item name="android:stretchColumns">*</item>
<item name="android:background">#FFDDDDDD</item>
</style>
<style name="CustomToolbarButton">
<item name="android:layout_weight">1</item>
<item name="android:background">@drawable/custom_toolbar_button</item>
<item name="android:textSize">12dp</item>
<item name="android:textColor">@color/custom_toolbar_button_text_color</item>
</style>
<style name="CustomToolbarButtonHomepage" parent="CustomToolbarButton">
<item name="android:drawableTop">@drawable/icon_dashboard</item>
</style>
<style name="CustomToolbarButtonNotification" parent="CustomToolbarButton">
<item name="android:drawableTop">@drawable/notification</item>
</style>
<style name="CustomToolbarButtonBrowse" parent="CustomToolbarButton">
<item name="android:drawableTop">@drawable/feeds</item>
</style>
<style name="CustomToolbarButtonProfile" parent="CustomToolbarButton">
<item name="android:drawableTop">@drawable/settings</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment