Posts

Showing posts with the label Android Support Library

Android : Control Smooth Scroll Over Recycler View

Answer : It's unclear what you mean when you say " smoothScroll ". You could be referring to the automatic " smoothScrollToPosition " which will automatically scroll to a specified position, you could be talking about manual scrolling and you could be talking about flinging. For the sake of prosperity, I will attempt to answer all of these issues now. 1. Automatic smooth scrolling. Inside your layout manager, you need to implement the smoothScrollToPosition method: @Override public void smoothScrollToPosition(RecyclerView recyclerView, State state, int position) { // A good idea would be to create this instance in some initialization method, and just set the target position in this method. LinearSmoothScroller smoothScroller = new LinearSmoothScroller(getContext()) { @Override public PointF computeScrollVectorForPosition(int targetPosition) { int yDelta = calculateC...

Android VectorDrawables.useSupportLibrary = True Is Stopping App

Answer : You cannot use Vector Drawables in any other views except ImageView in pre-lollipop. Please see this SO Answer by google developer advocate. For AppCompat users, we’ve decided to remove the functionality which let you use vector drawables from resources on pre-Lollipop devices due to issues found in the implementation in version 23.2.0/23.2.1 [ https://code.google.com/p/android/issues/detail?id=205236, https://code.google.com/p/android/issues/detail?id=204708 ]. Using app:srcCompat and setImageResource() continues to work. If you want to use the Vector Drawables pre-lollipop, use can set it programatically by converting it into a drawable. Drawable drawable; if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { drawable = context.getResources().getDrawable(drawableResId, context.getTheme()); } else { drawable = VectorDrawableCompat.create(context.getResources(), drawableResId, context.getTheme()); } button.setCompoundDrawablesWithIn...

Android Bottom Navigation Bar With Drop Shadow

Answer : You can draw your own shadow just above the bottom bar using simple View and its background: <View android:layout_width="match_parent" android:layout_height="4dp" android:layout_above="@id/bottom_bar" android:background="@drawable/shadow"/> drawable/shadow.xml: <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#1F000000" android:endColor="@android:color/transparent" android:angle="90" /> </shape> Also, there are no compatibility issues if use this approach. You can use elevation to add shadows to any view <TextView android:id="@+id/myview" ... android:elevation="2dp" android:background="@drawable/myrect" /> Refer this for more information For those using a CoordinatorLayout with the Bottom Navigation Bar (or BottomAppBar ), you can ...

Cannot Install Support Repository And Sync Project In Android Studio

Answer : Previously the Android Support Library dependencies were downloaded from Android SDK Manager. Now all the new versions are available from Google's Maven repository. In future all android libraries will be distributed through maven.google.com So, by adding the below code to the repositories will build the project. repositories { maven { url "https://maven.google.com" } } I had to add the following to my project level build.gradle. Then the button to install and worked. allprojects { repositories { maven { url "https://maven.google.com" } jcenter() } } Try using the latest support library versions: compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:design:25.3.1' compile 'com.google.android.gms:play-services-vision:10.2.1' compile 'com.android.volley:volley:1.0.0' //...