Here is good tutorial.
Drag and Swipe with RecyclerView
Friday, October 6, 2017
Tuesday, August 8, 2017
Working with images
If you're working with images (as background for example) you could face with big sizes of files.
Something like JPEG file 1280X1920px could take about 0.5 - 1.0M depending of content.
And it increases APK size!
Very nice solution I found is WebP.
You can download one of converters here: xnconvert
In my case I have following result: 789kb -> 96 kb (80% quality)
Something like JPEG file 1280X1920px could take about 0.5 - 1.0M depending of content.
And it increases APK size!
Very nice solution I found is WebP.
You can download one of converters here: xnconvert
In my case I have following result: 789kb -> 96 kb (80% quality)
Thursday, July 13, 2017
Friday, July 7, 2017
Market coverage by Android app with minSdkVersion
According google report July 6, 2017. we have following situation:
Version | Codename | API | Distribution | Coverage by app with minSdkVersion |
2.3.3 - 2.3.7 | Gingerbread | 10 | 0.70% | 100.00% |
4.0.3 - 4.0.4 | Ice Cream Sandwich | 15 | 0.70% | 99.30% |
4.1.x |
Jelly Bean
| 16 | 2.80% | 98.60% |
4.2.x | 17 | 4.10% | 95.80% | |
4.3 | 18 | 1.20% | 91.70% | |
4.4 | KitKat | 19 | 17.10% | 90.50% |
5 |
Lollipop
| 21 | 7.80% | 73.40% |
5.1 | 22 | 22.30% | 65.60% | |
6 | Marshmallow | 23 | 31.80% | 43.30% |
7 |
Nougat
| 24 | 10.60% | 11.50% |
7.1 | 25 | 0.90% | 0.90% |
So, if you're developing with minSdkVersion=21 you cover about 3/4 of market.
And if you're developing with minSdkVersion=19 you cover more than 9/10 of market.
And if you're developing with minSdkVersion=19 you cover more than 9/10 of market.
Friday, April 21, 2017
Friday, December 23, 2016
How to intercept event Soft keyboard shown/hidden
This is solution that is composed of code from SO and my enhancement to support various API levels.
Inspired by SO post http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
Updated 1/24/2017
Updated 15 Apr. 2017
I hope, this solution is final.
Preparation class:
Inspired by SO post http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
I hope, this solution is final.
Preparation class:
package my.package.utils; import android.graphics.Rect; import android.os.Build; import android.view.View; import android.view.ViewTreeObserver; import java.util.LinkedList; import java.util.List;public class SoftKeyboardStateWatcher implements ViewTreeObserver.OnGlobalLayoutListener { public void onStart() { isSoftKeyboardOpened = false; } public interface SoftKeyboardStateListener { void onSoftKeyboardOpened(int keyboardHeightInPx); void onSoftKeyboardClosed(); } private SoftKeyboardStateListener listener; private final View activityRootView; private boolean isSoftKeyboardOpened; private int resize; private int mKeyboardHeight; public SoftKeyboardStateWatcher( View activityRootView, SoftKeyboardStateListener listener ) { this(activityRootView, false); this.listener = listener; } private SoftKeyboardStateWatcher( View activityRootView, boolean isSoftKeyboardOpened ) { this.activityRootView = activityRootView; this.isSoftKeyboardOpened = isSoftKeyboardOpened; activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(this); } @Override public void onGlobalLayout() { Rect r = new Rect(); activityRootView.getWindowVisibleDisplayFrame(r); int heightDiff = activityRootView.getRootView().getHeight() - (r.bottom - r.top); int correction = r.top; if (!isSoftKeyboardOpened && heightDiff > correction && heightDiff > getStatusBarHeight() + getNavBarHeight()) { isSoftKeyboardOpened = true; notifyOnSoftKeyboardOpened(heightDiff, correction); } else { if (isSoftKeyboardOpened && heightDiff <= correction) { isSoftKeyboardOpened = false; notifyOnSoftKeyboardClosed(); }else{ if (!isSoftKeyboardOpened) return; if (mKeyboardHeight == heightDiff - correction) return; //Keyboard height has changed } } } private void notifyOnSoftKeyboardOpened(int keyboardHeightInPx, int correction) { if (listener == null) return; mKeyboardHeight = keyboardHeightInPx - correction; listener.onSoftKeyboardOpened(keyboardHeightInPx); } private void notifyOnSoftKeyboardClosed() { if (listener == null) return; listener.onSoftKeyboardClosed(); } public void removeSoftKeyboardStateListener() { listener = null; } private int getStatusBarHeight() { int result = 0; Resources resources = activityRootView.getResources(); int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = resources.getDimensionPixelSize(resourceId); } return result; } private int getNavBarHeight() { Resources resources = activityRootView.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { return resources.getDimensionPixelSize(resourceId); } return 0; } public boolean isSoftKeyboardOpened() { return isSoftKeyboardOpened; } }
The next step:Your activity must implementSoftKeyboardStateWatcher.SoftKeyboardStateListenerDeclare in your activityprotected SoftKeyboardStateWatcher mSoftKeyboardStateWatcher;
And run following code in onCreate:
int rootId = getRootId();//here you must supply root View id View root; if (rootId == 0 || (root = findViewById(rootId)) == null) return; mSoftKeyboardStateWatcher = new SoftKeyboardStateWatcher(root); mSoftKeyboardStateWatcher.addSoftKeyboardStateListener(his);Now you have these methods:@Override
public void onSoftKeyboardOpened(int keyboardHeightInPx) { } @Overridepublic void onSoftKeyboardClosed() { }
Also do not forget to remove listener:
@Override
public void onDestroy() { if (mSoftKeyboardStateWatcher != null) mSoftKeyboardStateWatcher.removeSoftKeyboardStateListener(this); super.onDestroy(); }
Subscribe to:
Posts (Atom)