Headertab

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday 17 March 2016

BottomBar

Hello guys today we are learn about how to make selectable with animation BottomBar.So lets start..



Create new android project and follow below instructions..

activity_main.xml  



<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/Container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="16dp"/>


MainActivity.xml



public class MainActivity extends AppCompatActivity {

    private BottomBar bottomBar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        bottomBar = BottomBar.attach(this, savedInstanceState);
        bottomBar.setFragmentItems(getSupportFragmentManager(), R.id.Container,
                new BottomBarFragment(HomeFragment.getInstance(), R.drawable.ic_home, "Home"),
                new BottomBarFragment(AndroidFragment.getInstance(), R.drawable.ic_android, "Android"),
                new BottomBarFragment(FavoriteFragment.getInstance(), R.drawable.ic_favorite, "Favorites"),
                new BottomBarFragment(GalleryFragment.getInstance(), R.drawable.ic_media, "Gallery")

        );

    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        bottomBar.onSaveInstanceState(outState);
    }
}

HomeFragment.java



public class AndroidFragment extends Fragment {

    TextView textView;
    View view;

    static AndroidFragment fragment=new AndroidFragment();
    public static AndroidFragment getInstance()
    {
        return fragment;
    }
    public AndroidFragment() {
        // Required empty public constructor
   
}


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
       
view=inflater.inflate(R.layout.fragment_android, container, false);
        textView= (TextView) view.findViewById(R.id.android);
        return view;
    }

}

Thank you.
If you want full source code click below link...

Source code





Live Sample





I hope helps this blog.


No comments:

Post a Comment