How to change system navigation bar color

Starting from API 27, it is now possible to use the light style of the navigation bar: <item name=”android:navigationBarColor”>@android:color/white</item> <item name=”android:windowLightNavigationBar”>true</item> From the documentation: windowLightNavigationBar If set, the navigation bar will be drawn such that it is compatible with a light navigation bar background. For this to take effect, the window must be drawing the … Read more

How can I modify ripple color when using ?attr/selectableItemBackground as background?

Finally I find the solution: instead of using android:colorControlHighlight directly in theme SelectableItemBackground, I should write another style: <style name=”SelectableItemTheme”> <item name=”colorControlHighlight”>@color/ripple_color</item> </style> Then: <style name=”SelectableItemBackground”> <item name=”android:theme”>@style/SelectableItemTheme</item> <item name=”android:background”>?attr/selectableItemBackground</item> </style> Finally add style=”@style/SelectableItemBackground” to View in layout.xml. UPDATED ON 2016/8/26 After N’s release, I found that sometimes we cannot use this method to set … Read more

OnClickListener for CardView?

You should implement the OnItemClickListener in your ViewHolder class, and pass the current item to the ViewHolder instances on every onBindViewHolder(). From this post: public static class ViewHolder extends RecyclerView.ViewHolder { public View view; public Item currentItem; public ViewHolder(View v) { super(v); view = v; view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // … Read more

Understanding RecyclerView setHasFixedSize

A very simplified version of RecyclerView has: void onItemsInsertedOrRemoved() { if (hasFixedSize) layoutChildren(); else requestLayout(); } This link describes why calling requestLayout might be expensive. Basically whenever items are inserted, moved or removed the size (width and height) of RecyclerView might change and in turn the size of any other view in view hierarchy might … Read more

application content goes behind the navigation bar in android L

Here is the solution. Most of the layouts get solved by adding these properties in values-v21 style.xml <item name=”android:windowTranslucentStatus”>true</item> <item name=”android:windowTranslucentNavigation”>true</item> <item name=”android:fitsSystemWindows”>true</item> for others, I have calculated the hight of navigation bar and add margin to my view . public static int getSoftButtonsBarSizePort(Activity activity) { // getRealMetrics is only available with API 17 and … Read more