Floating Action Button not showing fully inside a fragment

It’s not an acceptable solution to have to show/hide the FAB whatever tab is selected. I’ve tried every layout combination, but moving the FAB to the activity layout was the only solution that worked. But what if you need the button only in one tab? It’s the only way that works now, but I’m expecting … Read more

Can’t use srcCompat for ImageViews in android

Don’t android:srcCompat=”https://stackoverflow.com/questions/35645148/@drawable/wallpaper” Do app:srcCompat=”https://stackoverflow.com/questions/35645148/@drawable/wallpaper” as it srcCompat attribute is actually defined within AppCompat library. Important you will need to add appropriate namespace for this. xmlns:app=”http://schemas.android.com/apk/res-auto” Important what you are getting it seems like it is just a lint error that can be ignored. I have tried and have the same error, but it is working … Read more

Add app bar scrolling view behavior to multiple views in CoordinatorLayout

You don’t need a workaround or something strange. This behaviour is supported by the library. Just replace your LinearLayout by this and put it below the RecyclerView: <android.support.v4.widget.NestedScrollView android:layout_width=”match_parent” android:layout_height=”wrap_content” app:layout_behavior=”@string/appbar_scrolling_view_behavior”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” android:gravity=”center”> <Button android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:padding=”15dp” android:text=”Button text”/> </LinearLayout> </android.support.v4.widget.NestedScrollView> Also you will need to put this in your RecyclerView to … Read more

How to reset the Toolbar position controlled by the CoordinatorLayout?

To reset the scroll state, just get the AppBarLayout.Behavior object CoordinatorLayout coordinator = (CoordinatorLayout) findViewById(R.id.coordinator); AppBarLayout appbar = (AppBarLayout) findViewById(R.id.appbar); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appbar.getLayoutParams(); AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior(); and call onNestedPreScroll method manually: int[] consumed = new int[2]; behavior.onNestedPreScroll(coordinator, appbar, null, 0, -1000, consumed); If you would like to reset smoothly with an … Read more

NavigationView menu items with counter on the right

Starting from version 23 of appcompat-v7 NavigationView supports action views, so it is quite easy to implement counter yourself. Create counter layout, i.e. menu_counter.xml: <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”match_parent” android:gravity=”center_vertical” android:textAppearance=”@style/TextAppearance.AppCompat.Body2″ /> Reference it in your drawer menu xml, i.e. menu/drawer.xml: <item … app:actionLayout=”@layout/menu_counter” /> Note that you should use app namespace, don’t … Read more

TextInputLayout :How to give padding or margin to hint?

The solution proposed by ganesh2shiv works for the most part, although I’ve found it also de-centres the hint text displayed inside the EditText when not focused. A better trick is to set the desired paddingTop to the EditText but also embed the extra padding within the EditText’s background. A fairly sane way to do this … Read more

How can I change the NavigationView’s item text size?

Create new style at the file app/src/main/res/values/styles.xml <style name=”NavigationDrawerStyle”> <item name=”android:textSize”>20sp</item><!– text size in menu–> <!– item size in menu–> <item name=”android:listPreferredItemHeightSmall”>40dp</item> <item name=”listPreferredItemHeightSmall”>40dp</item> <!– item padding left in menu–> <item name=”android:listPreferredItemPaddingLeft”>8dp</item> <item name=”listPreferredItemPaddingLeft”>8dp</item> <!– item padding right in menu–> <item name=”android:listPreferredItemPaddingRight”>8dp</item> <item name=”listPreferredItemPaddingRight”>8dp</item> </style> Add it to your main_layout.xml <android.support.design.widget.NavigationView … app:theme=”@style/NavigationDrawerStyle” ….> </android.support.design.widget.NavigationView> … Read more

Support library VectorDrawable Resources$NotFoundException

It took 3 separate things for me to get this to work using support library 23.4.0: Add this to build.gradle defaultConfig { vectorDrawables.useSupportLibrary = true } Add the following to onCreate of your Application class AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); (From the reference of this link – “https://stackoverflow.com/a/45582033/10752962”) In API less then 21,use this line before setContentView(); For all … Read more

How to set the divider between Tabs in TabLayout of design support library?

TabLayout is actually HorizontalScrollView and it’s first child is LinearLayout. So just use below code to add dividers View root = tabLayout.getChildAt(0); if (root instanceof LinearLayout) { ((LinearLayout) root).setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); GradientDrawable drawable = new GradientDrawable(); drawable.setColor(getResources().getColor(R.color.separator)); drawable.setSize(2, 1); ((LinearLayout) root).setDividerPadding(10); ((LinearLayout) root).setDividerDrawable(drawable); } Below is the sample screen shot Screen 1 Screen 2

BottomSheetDialogFragment – How to set expanded height (or min top offset)

The height is being wrapped because the inflated view is added to the FrameLayout which has layout_height=wrap_content. See FrameLayout (R.id.design_bottom_sheet) at https://github.com/dandar3/android-support-design/blob/master/res/layout/design_bottom_sheet_dialog.xml. The class below makes the bottom sheet full screen, background transparent, and fully expanded to the top. public class FullScreenBottomSheetDialogFragment extends BottomSheetDialogFragment { @CallSuper @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)