CollapsingToolbarLayout setTitle() does not update unless collapsed

EDIT: This solution is no longer needed. bug fixed in v22.2.1 I didnt want to just leave links so here is the full solution. The bug occurs because the code to handle the collapsable title only updates the actual title if the current title is null or the text size has changed. The workaround is … Read more

Android TabLayout Android Design

I’ve just managed to setup new TabLayout, so here are the quick steps to do this (ノ◕ヮ◕)ノ*:・゚✧ Add dependencies inside your build.gradle file: dependencies { compile ‘com.android.support:design:23.1.1’ } Add TabLayout inside your layout <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical”> <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”?attr/colorPrimary”/> <android.support.design.widget.TabLayout android:id=”@+id/tab_layout” android:layout_width=”match_parent” android:layout_height=”wrap_content”/> <android.support.v4.view.ViewPager android:id=”@+id/pager” android:layout_width=”match_parent” android:layout_height=”match_parent”/> </LinearLayout> … Read more

Getting exception : java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14

I resolved this issue and if anyone is experiencing this issue try these options(3rd point fixed my problem): Add multiDexEnabled true in defaultConfig of build.gradle. defaultConfig { applicationId “com.something.ranjith.androidprojdel” minSdkVersion 15 targetSdkVersion 22 versionCode 1 versionName “1.0” multiDexEnabled true } Remove android support library if your activity extends `AppcompatActivity’ compile ‘com.android.support:support-v4:22.+’ //remove this If you … Read more

How to change android design support library FAB Button border color?

you can make circle without drawable <android.support.design.widget.FloatingActionButton android:id=”@+id/bottom_navigation_fab” style=”@style/fab_material” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentBottom=”true” android:layout_centerInParent=”true” android:layout_gravity=”bottom|center” app:borderWidth=”3dp” android:backgroundTint=”@color/mountain_meadow” // inner circle color android:layout_marginBottom=”10dp” android:tint=”@color/white” app:backgroundTint=”@color/white” // border color app:srcCompat=”@drawable/bottom_nav_star” /> output :

Android support v23.1.0 update breaks NavigationView get/find header

With the design library v 23.1.0 the NavigationView works with a RecyclerView. Also the Header is now a type of row. It means that the header could not be immediately available in the view hierarchy. It can cause issues if you are using methods like navigationView.findViewById(XXX) to get a view inside the header. There is … Read more

How can I determine that CollapsingToolbar is collapsed?

As Marko said, this can be achieved using your own implementation of a OnOffsetChangedListener. AppBarLayout appBarLayout = (AppBarLayout) view.findViewById(R.id.app_bar_layout); appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) { // Collapsed } else if (verticalOffset == 0) { // Expanded } else { // Somewhere in between } } … Read more

TabLayout tab style

Define: <style name=”AppTabLayout” parent=”Widget.Design.TabLayout”> <item name=”tabMaxWidth”>@dimen/tab_max_width</item> <item name=”tabIndicatorColor”>?attr/colorAccent</item> <item name=”tabIndicatorHeight”>4dp</item> <item name=”tabPaddingStart”>6dp</item> <item name=”tabPaddingEnd”>6dp</item> <item name=”tabBackground”>?attr/selectableItemBackground</item> <item name=”tabTextAppearance”>@style/AppTabTextAppearance</item> <item name=”tabSelectedTextColor”>@color/range</item> </style> <!– for text –> <style name=”AppTabTextAppearance” parent=”TextAppearance.Design.Tab”> <item name=”android:textSize”>12sp</item> <item name=”android:textColor”>@color/orange</item> <item name=”textAllCaps”>false</item> </style> Apply: <android.support.design.widget.TabLayout style=”@style/AppTabLayout” app:tabTextAppearance=”@style/AppTabTextAppearance” android:layout_width=”match_parent” …. />

Set starting height of CollapsingToolbarLayout

Actually AppBarLayout has special method to apply such offset: final int setAppBarTopBottomOffset(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int newOffset, int minOffset, int maxOffset) Unfortunately it has package-private access level, but we can invoke it through such intermediate chain: private void setAppBarOffset(int offsetPx){ CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams(); AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior(); behavior.onNestedPreScroll(mCoordinatorLayour, mAppBarLayout, null, 0, offsetPx, … Read more

Disable icon colorStateList in NavigationView

Is there no way for me to force NavigationView to stop tinting my icons? There sure is. You can do so programmatically using NavigationView.setItemIconTintList. And you can do so in your XML layout by using the NavigationView.itemIconTint attribute. Programmatically yourNavigationView.setItemIconTintList(null); From XML <android.support.design.widget.NavigationView … app:itemIconTint=”@android:color/black” … /> Results