ismaeldivita / chip-navigation-bar Goto Github PK
View Code? Open in Web Editor NEWAn android navigation bar widget
License: MIT License
An android navigation bar widget
License: MIT License
tab
I have following menu file but android:enabled="true"
is not working (I mean by default when I open my app it is not active)
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/home"
android:icon="@drawable/abc_vector_test"
android:title="Home"
android:enabled="true"
app:cnb_iconColor="@color/home" />
<item
android:id="@+id/activity"
android:icon="@drawable/ic_launcher_foreground"
android:title="@string/services"
app:cnb_iconColor="@color/services" />
<item
android:id="@+id/favorites"
android:icon="@android:drawable/arrow_down_float"
android:title="@string/orders"
app:cnb_iconColor="@color/orders" />
<item
android:id="@+id/settings"
android:icon="@android:drawable/arrow_up_float"
android:title="@string/settings"
app:cnb_iconColor="@color/settings" />
</menu>
how to remove animation in text of tab bar?
Thanks for a great library.
I am tring to achiving something similar to like this.
I have implemented it but navigation bar didn't animated.
Can you please help me out.
Thanks
Is there any way to change the icon of a menu item from code? For example set a drawable as an image when a user logs in?
How to Add fragments instead of colors
when click on chip i want to add fragment in container like that
or add fragments in arraylist and pass to chip navigation bar
ArrayList fragList = new ArrayList<>();
fragList.add(new firstFragement());
4 more.
please look in to it
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.72'
I have imported project successfully
And yet cant use app:cnb_menuResource
in my XML file.
Android max API 30
min API level 23
Sync with Gradle and cleared caches and restarted no use.
I am not sure what I have to write in the OnItemSelctedListener in Java can you send me an Example sir?
This is a Part of my Current Code what do it Need to Change? i want to open an New Actvity on Click Item
public class MainActivity extends AppCompatActivity {
ChipNavigationBar chipNavigationBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_test);
chipNavigationBar = findViewById(R.id.menu);
chipNavigationBar.setOnItemSelectedListener(new ChipNavigationBar.OnItemSelectedListener() {
@Override
public void onItemSelected(int id) {
Toast.makeText(MainActivity.this, "Test", Toast.LENGTH_SHORT).show();
}
});
}
excuse me sir, ive tried your library but idk how to use this with setupWithNavController method
Is there a way to change the font family?
I am trying to init it with a view pager so I need to set the selected item when fragments are selected in the view pager but mbn.setItemSelected(0, true);
has no effect and no items are selected.
Class referenced in the layout file, com.ismaeldivita.chipnavigation.ChipNavigationBar, was not found in the project or the libraries
Unable to use onNavigationItemSelected in Java
It cannot be used with navcontroller
chipNavigationBar.setItemSelected(getSelectedItemId, false)
trying to use this method to deselect a particular item . But it doesn't work
click Menu not working please how to fix this issue
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".ui.MainActivity">
<FrameLayout
android:id="@+id/fragmentLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottomMenu"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.ismaeldivita.chipnavigation.ChipNavigationBar
android:id="@+id/bottomMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cnb_menuResource="@menu/bottom_menu"
app:cnb_orientationMode="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Kotlin
class MainActivity : AppCompatActivity() {
private val binding : ActivityMainBinding by lazy {
ActivityMainBinding.inflate(layoutInflater)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setupFragment(PlanningFragment())
setupNavigation()
}
private fun setupNavigation() {
with(binding) {
bottomMenu.setItemSelected(R.id.home)
bottomMenu.setOnItemSelectedListener {
when (it) {
R.id.menu_planing -> setupFragment(PlanningFragment())
R.id.menu_notes -> setupFragment(NotesFragment())
R.id.menu_link -> setupFragment(LinkFragment())
}
}
}
}
private fun setupFragment(fragment : Fragment) {
val transaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.fragmentLayout, fragment)
transaction.commit()
}
}
can you add get menu to change menu item title dynamically ?
When I run the application it works with no error. I have 4 buttons in my chip navigation bar. When I click on the first three buttons it doesn't click on the button that I clicked, it automatically clicks the last button. How can I fix that bug? (I'm working with Java)
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@fa524d7
W/System: A resource failed to call close.
W/System: A resource failed to call close.
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
I/chatty: uid=10086(com.example.quitter) RenderThread identical 2 lines
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@f4f37fa
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
I/chatty: uid=10086(com.example.quitter) RenderThread identical 1 line
D/EGL_emulation: eglMakeCurrent: 0xe6f85300: ver 2 0 (tinfo 0xe6f832c0)
chipNavigationBar.setOnItemSelectedListener(new ChipNavigationBar.OnItemSelectedListener() {
@Override
public void onItemSelected(int i) {
if (i==R.id.menu_home) {
LoadFrag(new HomeFrag());
} else if (i == R.id.menu_fav) {
LoadFrag(new FavFrag());
}
}
});
while useing above event iam geting error as below during compiling
error: cannot access Function1
class file for kotlin.jvm.functions.Function1 not found
I need to set one of the items as default selected when the view is shown. Right now all items are unselected. How can I make this?
Can we use it with view pager and fragments?
when i use the dependencies, the "tools:context" field of every layout file shows error.
i am using it with java so used this dependencies:
implementation 'com.ismaeldivita.chipnavigation:chip-navigation-bar:1.3.2'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.72'
the error shows " Unresolved class 'class_name' ".
please help me with this.
How to increase the speed of animation in button click?
While clicking on a Chip on the bottom navbar, I see quite some amount of lag.
I hope this can be fixed :)
I already do selector.xml for each icon and i program each icon for true and false android:state_checked. but it didn't work. did anyone have the solution?
So when I am clicking on one item once, the fragment matching with the clicked item id is being called twice. I don't think this is happening because of my code.
bottomBar is the chip-navigation-bar
binding.bottomBar.setOnItemSelectedListener { id -> when (id) { R.id.home1 -> { setFragment(HomeFragment1()) } R.id.home2 -> { setFragment(HomeFragment2()) } R.id.home3 -> { setFragment(HomeFragment3()) } } }
Is there any way to change the text and icon of a menu item programmatically? For eg:if the user has a store. need to show the store image and store name on fourth item
Pls help me on this.
there is no way to change the color of the text
Tried textAppearance but it doesn't work with textColor, it always follows the theme's primary color
val navController = findNavController(R.id.nav_host_fragment)
binding.bottomNav.setupWithNavController(navController)
binding.bottomNav.setOnNavigationItemReselectedListener {/* NO-OP */ }
I tried a method but the app crash. How can I solve this?
Hello @ismaeldivita
Please make this library for java compatible, so we can use in java project also. It is very good looking working is there.
Thanks
my mainactivity.java code is
package com.asus.eins;
import androidx.annotation.MenuRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.widget.Toast;
import com.asus.eins.Fragment.Home;
import com.ismaeldivita.chipnavigation.ChipNavigationBar;
import java.util.ArrayList;
import java.util.List;
public class Dashboard extends AppCompatActivity {
ChipNavigationBar chipNavigationBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
chipNavigationBar = findViewById(R.id.menu);
chipNavigationBar.setOnItemSelectedListener(new ChipNavigationBar.OnItemSelectedListener() {
@Override
public void onItemSelected(int id) {
switch (id) {
case R.id.home:
chipNavigationBar.setMenuResource(R.layout.fragment_home);
break;
}
}
});
}
}
and my mainactivity.xml is
<com.ismaeldivita.chipnavigation.ChipNavigationBar
android:id="@+id/menu"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:background="#fff"
android:elevation="16dp"
android:gravity="center"
android:padding="8dp"
app:cnb_menuResource="@menu/bottom_menu" >
</com.ismaeldivita.chipnavigation.ChipNavigationBar>
i set on item selected with my fragment
but when i clicked a item menu my app is force close and show a error expecting menu, got relative layout
"java.lang.NullPointerException: Attempt to invoke virtual method 'void com.ismaeldivita.chipnavigation.ChipNavigationBar.setOnItemSelectedListener(com.ismaeldivita.chipnavigation.ChipNavigationBar$OnItemSelectedListener)' on a null object reference"
great library so far. How can I implement the delegate method in Java?
... setOnItemSelectedListener( ...
please provide this in java so that this library can be used for java project. it is not working in java project .
I am implementing the current last version 1.3.3
but get this error
AAPT: error: duplicate value for resource 'attr/pivotX' with config ''.
It is basically because it uses the beta version of the constraint layout 2.0.0beta6
so when I reduce it to the stable version 1.1.3
some packages that are used by this library are not there yet! e.g. androidx.constraintlayout.helper
Hi! I have tried to add it to my java project. I've added both dependencies, but I can't use the "app:cnb....
" atributes on my XML files. How can it be solved?
Thanks
I want to make each menu item open a new activity but I'm having trouble implementing this method. Can someone explain to me how I should do it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.