Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Wednesday, October 21, 2015

ANDROID - align linearlayout each one behind other programmatically

http://stackoverflow.com/questions/12108370/how-to-setcontentview-in-a-fragment

The method setContent(relativeLayout) on Activity in case of Fragments need to be replaced with return this relatiVeLayout from onCreateView or do from onViewCreated this:

RelativeLayout rootContainer = (RelativeLayout)mainActivity.findViewById(R.id.rootContainer);
rootContainer.addView(rl);

Saturday, October 3, 2015

ANDROID - how to enable your mobile phone for Android Studio on Windows

Case:
You want to run/debug Android app on your phone (e.g. Samsung Galaxy  S2) instead of emulator (which sucks), but Android Studio (Windows version of it) can not see it among available devices.

Solution:
FIRST OF ALL The last thing you will think it is important, but it is indeed: install on Windows USB drivers for you phone model!!! 
For instance:
Samsung Galaxy S2http://www.samsung.com/us/support/owners/product/SGH-I777ZKAATT
LG L9http://www.lg.com/us/support-mobile/lg-LGP769BK
Then enable some phone settings:
Developer options / USB debugging
Security / Unknown sources (Allow installation of apps from sources other than Play Store)

Tuesday, March 4, 2014

How to hide action bar before activity is created (link)

I had to solve somehow the issue when default actionbar is shown right before I've to inflate the custom view for it. I've found this link with good explanation how to fix it.

Wednesday, February 19, 2014

Android - How to apply color filter over ImageView component (link)

http://stackoverflow.com/questions/8193447/i-want-to-add-a-color-filter-to-the-imageview

If you want to use your predefined colours get them this way e.g. :
v.setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_ATOP);

Tuesday, February 11, 2014

Android - How to force use of overflow menu on devices with menu button

http://stackoverflow.com/questions/9286822/how-to-force-use-of-overflow-menu-on-devices-with-menu-button

try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if(menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

Saturday, February 1, 2014

LINUX UBUNTU 12.04 64-bit and Android SDK 32-bit issue - gradle: Cannot run program sdk build-tools android-4.4 aapt No such file or directory

If you got this kind of error during the building of Android app: Execution failed for task mergeDebugResources Cannot run program sdk build-tools android-4.4 aapt No such file or directory -- this happen because you run Android SDK 32-bit on Linux Ubuntu 12.04 64-bit.

You can fix it easily by installing this libraries:
sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1

More about this issue here:
http://askubuntu.com/questions/147400/problems-with-eclipse-and-android-sdk
http://stackoverflow.com/questions/18928164/android-studio-cannot-find-aapt
 

Monday, January 13, 2014

Get the view size and position on ViewTreeObserver

If you have to get view's position coordinates, size and etc do it using ViewTreeObserver class.

Read this article:
http://stackoverflow.com/questions/7733813/how-can-you-tell-when-a-layout-has-been-drawn

How to update your Android apps

In one sentance:
Open on your mobile Play Store app, find out the app you want to update among the installed apps and run update process.

Read more about it here:
http://www.pcadvisor.co.uk/how-to/google-android/3435989/how-update-android-apps/

Saturday, January 11, 2014

Getting View's coordinates relative to the root layout

If you get only ZERO's by view.getLeft()... try to use
view.getLocationOnScreen() and/or getLocationInWindow().

Here is the link of this issue:
http://stackoverflow.com/questions/2224844/how-to-get-the-absolute-coordinates-of-a-view