How I can remove the unnecessary top padding of the Navigation view?

You can override predefined dimensions at your dimens.xml as; <dimen name=”design_navigation_padding_top_default” tools:override=”true”>0dp</dimen> <dimen name=”design_navigation_separator_vertical_padding” tools:override=”true”>0dp</dimen> <dimen name=”design_navigation_padding_bottom” tools:override=”true”>0dp</dimen> Other possible values are here: https://github.com/android/platform_frameworks_support/blob/master/design/res/values/dimens.xml

Add elevation/shadow on toolbar for pre-lollipop devices

For Android 5.0 and above : AppBarLayout automatically provides/gives shadow in the layout. You can also increase the elevation of the AppBarLayout by app:elevation=”4dp”. For Pre-Lollipop : You can use the following link: https://github.com/vipulasri/Toolbar-Elevation-Pre-Lollipop Note: Toolbar also supports elevation to it, using android:elevation=”4dp” New Update: In Appcompat v24.0.0, you can not set elevation to AppBarLayout … Read more

Android Circular Determinate ProgressBar

I have written detailed example on Android circular progress bar here on my blog demonuts.com You can also fond full source code and explanation there. Here’s how I made circular progressbar with percentage inside circle in pure code without any library. first create a drawable file called circular.xml <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:id=”@android:id/secondaryProgress”> … Read more

How to change Toolbar Navigation and Overflow Menu icons (appcompat v7)?

To change the navigation icon you can use: Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.my_icon); To change the overflow icon you can use the method: toolbar.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.ic_my_menu); If you would like to change the color of the icons you can use: with a Material Components Theme (with a MaterialToolbar for example): <com.google.android.material.appbar.MaterialToolbar android:theme=”@style/MyThemeOverlay_Toolbar” …> <style … Read more

how to highlight the selected Item of Recycler View?

You can use a StateListDrawable to achieve the desired effect. Example Create a new Drawable resource file in your drawable directory with the following content: selector_row.xml <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <!– Color when the row is selected –> <item android:drawable=”@android:color/darker_gray” android:state_pressed=”false” android:state_selected=”true” /> <!– Standard background color –> <item android:drawable=”@android:color/white” android:state_selected=”false” /> </selector> Now … Read more

Circular reveal transition for new activity

After looking for a solution for half a day without a result, I came up with an own implementation. I’m using a transparent activity with a matching root layout. The root layout is a view which can then be revealed with createCircularReveal(). My code looks like this: Theme Definition in styles.xml <style name=”Theme.Transparent” parent=”Theme.AppCompat.Light.NoActionBar”> <item … Read more

Android How to implement Bottom Sheet from Material Design docs

Edit The BottomSheet is now part of the android-support-library. See John Shelleys’ answer. Unfortunately there’s currently no “official” way on how to do this (at least none that I’m aware of). Luckily there’s a library called “BottomSheet” (click) which mimics the look and feel of the BottomSheet and supports Android 2.1 and up. In case … Read more

CardView not showing Shadow in Android L

After going through the docs again, I finally found the solution. Just add card_view:cardUseCompatPadding=”true” to your CardView and shadows will appear on Lollipop devices. What happens is, the content area in a CardView take different sizes on pre-lollipop and lollipop devices. So in lollipop devices the shadow is actually covered by the card so its … Read more

How can a divider line be added in an Android RecyclerView?

In the October 2016 update, the support library v25.0.0 now has a default implementation of basic horizontal and vertical dividers available! https://developer.android.com/reference/android/support/v7/widget/DividerItemDecoration.html recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL));