How to change the default color of DatePicker and TimePicker dialog in Android?

The best way to change the picker dialog is by adding custom style to it. <style name=”TimePickerTheme” parent=”Theme.AppCompat.Light.Dialog”> <item name=”colorAccent”>@color/color_primary</item> <item name=”android:layout_width”>wrap_content</item> <item name=”android:layout_height”>wrap_content</item> </style> TimePickerDialog timePicker = new TimePickerDialog(mContext, R.style.TimePickerTheme, fromListener, hour, min, false); Worked perfectly for me.

onClick method not working properly after NestedScrollView scrolled

I found solution for same problem on this thread :The item inside RecyclerView can’t be clicked right after scrolling You can fix your code by adding layout_behavior to your AppBarLayout.You can find code here Fixed AppBarLayout.Behavior .Just add this class tou your project and fix your code : <android.support.design.widget.AppBarLayout android:layout_width=”match_parent” app:layout_behavior=”yourPackageName.FixAppBarLayoutBehavior” android:layout_height=”wrap_content”>

Creating LinearLayout Programmatically/Dynamically with Multiple Views

You want that hierarchy programmatically. – LinearLayout(horizontal) – ImageView – LinearLayout(vertical) – TextView – TextView – TextView – TextView Ok lets start with Parent LinearLayout LinearLayout parent = new LinearLayout(context); parent.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); parent.setOrientation(LinearLayout.HORIZONTAL); //children of parent linearlayout ImageView iv = new ImageView(context); LinearLayout layout2 = new LinearLayout(context); layout2.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); layout2.setOrientation(LinearLayout.VERTICAL); parent.addView(iv); parent.addView(layout2); //children … Read more

Android adjustpan not working after the first time

This may seem a bit silly but I ran into this problem when I set the property gravity of my EditText to either ‘center_horizontal’ or ‘center’. The same problem occurs when using textAlignment ‘center’. Remove it and you won’t run into the problem of the keyboard hiding the EditText the second time (and subsequent ones) … Read more

How to access resource with dynamic name in my case?

int id = getResources().getIdentifier(imageName, type, package); This will get you the ID of the resource you are looking for. With it, you can then access the resource from the R class. Using only the name parameter: You can also include all the 3 info in the “name” parameter using the following format: “package:type/image_name”, something like: … Read more

Scrollview inside constraint layout does not scroll to the bottom of the parent constraint

This layout works in my app. The trick is to set these two attributes in ScrollView: android:layout_height=”0dp” app:layout_constraintBottom_toBottomOf=”parent” The simplified layout from my app: <?xml version=”1.0″ encoding=”utf-8″?> <android.support.constraint.ConstraintLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:theme=”@style/ThemeOverlay.AppCompat.Light”> <RelativeLayout android:id=”@+id/linear” android:layout_width=”0dp” android:layout_height=”56dp” android:background=”@color/title” app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintRight_toRightOf=”parent” app:layout_constraintTop_toTopOf=”parent” /> <ScrollView android:layout_width=”0dp” android:layout_height=”0dp” app:layout_constraintBottom_toBottomOf=”parent” app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintRight_toRightOf=”parent” app:layout_constraintTop_toBottomOf=”@id/linear”> <android.support.constraint.ConstraintLayout android:layout_width=”match_parent” android:layout_height=”wrap_content”> <TextView android:id=”@+id/titleView” … Read more

Make a ProgressBar update smoothly

The Interpolator has to be attached to an animation and this will work only on Honeycomb or higher: if(android.os.Build.VERSION.SDK_INT >= 11){ // will update the “progress” propriety of seekbar until it reaches progress ObjectAnimator animation = ObjectAnimator.ofInt(seekbar, “progress”, progress); animation.setDuration(500); // 0.5 second animation.setInterpolator(new DecelerateInterpolator()); animation.start(); } else seekbar.setProgress(progress); // no animation on Gingerbread or … Read more