Created
March 3, 2018 11:08
-
-
Save mhasby/e6d1dab353d65915811fd04d0223c0a8 to your computer and use it in GitHub Desktop.
Android Custom Bottom Navigation Bar (Colored Icon)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/colorBackground" | |
tools:context="id.codigo.klikdokter.MainActivity"> | |
<FrameLayout | |
android:id="@+id/fl_content" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:layout_above="@+id/bottom_navigation" /> | |
<app.custom.view.CustomNavigationView | |
android:id="@+id/custom_bottom_navigation" | |
android:layout_width="match_parent" | |
android:layout_height="58dp" | |
android:layout_alignParentBottom="true" | |
android:background="@drawable/bg_bottom_navbar" | |
android:paddingTop="3dp" | |
app:elevation="2dp" | |
app:customMenu="@menu/bottom_main"/> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<declare-styleable name="CustomNavigationView"> | |
<attr name="customMenu" format="reference" /> | |
<attr name="backgroundColor" format="color" /> | |
</declare-styleable> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_example); | |
CustomNavigationView customNavigation = findViewById(R.id.custom_bottom_navigation); | |
customNavigation.setOnNavigationItemSelectedListener(this); | |
customNavigation.setSelectedId(R.id.tab_chat); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment