Skip to content
Browse files

Add gif

Improve Demo
Improve Readme
  • Loading branch information...
1 parent 7465891 commit 4e6ab10e208c070b6a9ea7f4be34cb4fad425168 @aurelhubert committed
View
92 README.md
@@ -1,2 +1,90 @@
-# ahbottomnavigation
-A library to reproduce the behavior of the Bottom Navigation guidelines from Material Design.
+# AHBottomNavigation
+A library to reproduce the behavior of the Bottom Navigation guidelines from Material Design (minSdkVersion=16).
+
+# Demo
+<img src="https://raw.githubusercontent.com/aurelhubert/ahbottomnavigation/master/demo1.gif" width="278" height="492" /> <img src="https://raw.githubusercontent.com/aurelhubert/ahbottomnavigation/master/demo2.gif" width="278" height="492" /> <img src="https://raw.githubusercontent.com/aurelhubert/ahbottomnavigation/master/demo3.gif" width="278" height="492" /> <img src="https://raw.githubusercontent.com/aurelhubert/ahbottomnavigation/master/demo4.gif" width="278" height="492" />
+
+# Features
+
+* Follow the bottom navigation bar guidelines (https://www.google.com/design/spec/components/bottom-navigation.html)
+* Add 3 to 5 items (with title, icon & color)
+* Choose your style: Classic or colored navigation
+* Add a AHBottomNavigationListener to detect tab selection
+
+# How to?
+
+## Gradle
+```groovy
+buildscript {
+ repositories {
+ jcenter()
+ }
+}
+
+dependencies {
+ compile 'com.aurelhubert:ah-bottom-navigation:0.1'
+}
+```
+## XML
+```xml
+<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
+ android:id="@+id/bottom_navigation"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+```
+
+## Activity/Fragment
+```java
+AHBottomNavigation bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);
+
+// Create items
+AHBottomNavigationItem item1 = new AHBottomNavigationItem("Label One", R.drawable.ic_maps_place, Color.parseColor("#455C65"));
+AHBottomNavigationItem item2 = new AHBottomNavigationItem("Label Two", R.drawable.ic_maps_local_bar, Color.parseColor("#00886A"));
+AHBottomNavigationItem item3 = new AHBottomNavigationItem("Label Three", R.drawable.ic_maps_local_restaurant, Color.parseColor("#8B6B62"));
+
+// Add items
+bottomNavigation.addItem(item1);
+bottomNavigation.addItem(item2);
+bottomNavigation.addItem(item3);
+
+// Change colors
+bottomNavigation.setAccentColor(Color.parseColor("#F63D2B"));
+bottomNavigation.setInactiveColor(Color.parseColor("#747474"));
+
+// Use colored navigation with circle reveal effect
+bottomNavigation.setColored(isChecked);
+
+// Set listener
+bottomNavigation.setAHBottomNavigationListener(new AHBottomNavigation.AHBottomNavigationListener() {
+ @Override
+ public void onTabSelected(int position) {
+ // Do something cool here...
+ }
+});
+```
+## minSDK version
+
+The current minSDK version is API level 16.
+
+## Contributions
+
+Feel free to create issues / pull requests.
+
+## License
+
+```
+BottomBar library for Android
+Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
View
30 ahbottomnavigation/build.gradle
@@ -1,5 +1,29 @@
apply plugin: 'com.android.library'
+ext {
+ bintrayRepo = 'maven'
+ bintrayName = 'ah-bottom-navigation'
+
+ publishedGroupId = 'com.aurelhubert'
+ libraryName = 'AHBottomNavigation'
+ artifact = 'ahbottomnavigation'
+
+ libraryDescription = 'A library to reproduce the behavior of the Bottom Navigation guidelines from Material Design.'
+
+ siteUrl = 'https://github.com/aurelhubert/ahbottomnavigation'
+ gitUrl = 'https://github.com/aurelhubert/ahbottomnavigation.git'
+
+ libraryVersion = '0.1'
+
+ developerId = 'aurelhubert'
+ developerName = 'Aurelien Hubert'
+ developerEmail = 'aurel.hubert@gmail.com'
+
+ licenseName = 'The Apache Software License, Version 2.0'
+ licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ allLicenses = ["Apache-2.0"]
+}
+
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
@@ -8,7 +32,7 @@ android {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
- versionName "1.0"
+ versionName "0.1"
}
buildTypes {
release {
@@ -23,3 +47,7 @@ dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
}
+
+// Place it at the end of the file
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
+apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
View
13 ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
@@ -77,7 +77,7 @@ public AHBottomNavigation(Context context, AttributeSet attrs, int defStyleAttr)
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- initBottomNavigation();
+ initViews();
}
@Override
@@ -102,7 +102,7 @@ private void initColors() {
/**
* Init
*/
- private void initBottomNavigation() {
+ private void initViews() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setElevation(context.getResources().getDimension(R.dimen.bottom_navigation_elevation));
@@ -212,8 +212,7 @@ private void createClassicItems(LinearLayout linearLayout) {
setBackgroundColor(defaultBackgroundColor);
icon.setImageDrawable(AHHelper.getTintDrawable(context, items.get(i).getResource(),
currentItem == i ? accentColor : inactiveColor));
- title.setTextColor(currentItem == i ? accentColor :
- ContextCompat.getColor(context, R.color.colorInactive));
+ title.setTextColor(currentItem == i ? accentColor : inactiveColor);
}
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, currentItem == i ?
@@ -297,10 +296,7 @@ private void createSmallItems(LinearLayout linearLayout) {
ContextCompat.getColor(context, R.color.colorActiveSmall) :
ContextCompat.getColor(context, R.color.colorInactiveSmall));
} else {
-
setBackgroundColor(defaultBackgroundColor);
-
- Log.d(TAG, items.get(i).getTitle() + " / " + i + " / " + currentItem);
icon.setImageDrawable(AHHelper.getTintDrawable(context, items.get(i).getResource(),
currentItem == i ? accentColor : inactiveColor));
title.setTextColor(currentItem == i ? accentColor : inactiveColor);
@@ -587,6 +583,7 @@ public int getDefaultBackgroundColor() {
*/
public void setDefaultBackgroundColor(int defaultBackgroundColor) {
this.defaultBackgroundColor = defaultBackgroundColor;
+ createItems();
}
/**
@@ -605,6 +602,7 @@ public int getAccentColor() {
*/
public void setAccentColor(int accentColor) {
this.accentColor = accentColor;
+ createItems();
}
/**
@@ -623,6 +621,7 @@ public int getInactiveColor() {
*/
public void setInactiveColor(int inactiveColor) {
this.inactiveColor = inactiveColor;
+ createItems();
}
/**
View
2 app/src/main/AndroidManifest.xml
@@ -10,7 +10,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
- <activity android:name=".HomeActivity">
+ <activity android:name=".DemoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
View
10 .../com/ahbottomnavigation/HomeActivity.java → .../com/ahbottomnavigation/DemoActivity.java
@@ -5,13 +5,14 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SwitchCompat;
import android.widget.CompoundButton;
+import android.widget.TextView;
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
import java.util.ArrayList;
-public class HomeActivity extends AppCompatActivity {
+public class DemoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -28,6 +29,7 @@ private void initUI() {
final SwitchCompat switchColored = (SwitchCompat) findViewById(R.id.home_switch_colored);
final SwitchCompat switchFourItems = (SwitchCompat) findViewById(R.id.home_switch_four_items);
final AHBottomNavigation bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);
+ final TextView currentItem = (TextView) findViewById(R.id.home_current_item);
final ArrayList<AHBottomNavigationItem> items = new ArrayList<>();
AHBottomNavigationItem item1 = new AHBottomNavigationItem("Label One", R.drawable.ic_maps_place, Color.parseColor("#455C65"));
@@ -41,11 +43,13 @@ private void initUI() {
items.add(item3);
bottomNavigation.addItems(items);
- bottomNavigation.setAccentColor(Color.parseColor("#00E676"));
+ bottomNavigation.setAccentColor(Color.parseColor("#F63D2B"));
+ bottomNavigation.setInactiveColor(Color.parseColor("#747474"));
bottomNavigation.setAHBottomNavigationListener(new AHBottomNavigation.AHBottomNavigationListener() {
@Override
public void onTabSelected(int position) {
- //Toast.makeText(HomeActivity.this, "Select: " + position, Toast.LENGTH_SHORT).show();
+ //Toast.makeText(DemoActivity.this, "Select: " + position, Toast.LENGTH_SHORT).show();
+ currentItem.setText("Current item: " + position);
}
});
View
8 app/src/main/res/layout/activity_home.xml
@@ -51,6 +51,14 @@
</LinearLayout>
+ <TextView
+ android:id="@+id/home_current_item"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="24dp"
+ android:text="Current item: 0"
+ android:textSize="18sp"/>
+
</LinearLayout>
<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
View
5 build.gradle
@@ -6,9 +6,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
View
BIN demo1.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN demo2.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN demo3.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN demo4.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4e6ab10

Please sign in to comment.
Something went wrong with that request. Please try again.