How To Stop EditText From Gaining Focus On Activity Start
Posted by blogmeister on
February 17, 2014
There are times when we do not want the EditText component to gain focus and have the input keyboard show up.
What I wanted was the input keyboard to only show up when I tap on the EditText component.
Well, there is a solution to this without using code. Just add the attribute android:focusableInTouchMode=”true” in your layout where the EditText is part of and it won’t show the keyboard whenever the Activity starts.
Share the post "How To Stop EditText From Gaining Focus On Activity Start"
How To Auto Adjust Google AdMob Container On Orientation Change In Android
Posted by blogmeister on
January 29, 2014
There is no method to automatically change your Android app’s container size for showing Google AdMob ads. While it does re-adjust itself whenever the orientation changes, it does not resize itself to the correct size.
Try changing your device’s orientation from portrait to landscape mode and you will see that the height is the same. The result is that the height of the ad container shown is too big just like when its orientation is in portrait mode.
The workaround to make the ad container resize correctly according to orientation change like the image below is to remove the ad container in your layout view and add it back.
Say this is your code for adding the ad container view to your layout view.
|
1 2 3 4 5 6 7 8 |
private void configureAds() { FrameLayout fl = (FrameLayout) findViewById(R.id.adContainer); fl.removeAllViews(); AdSize adsize = com.google.ads.AdSize.SMART_BANNER; adView = new AdView(this, adsize, Default.ID_ADMOB); fl.addView(adView); adView.loadAd(new AdRequest()); } |
Then place the method in the onConfigurationChanged().
|
1 2 3 4 5 |
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); configureAds(); } |
Share the post "How To Auto Adjust Google AdMob Container On Orientation Change In Android"
tags: ad, admob, container, google, landscape, layout, onconfigurationchanged, orientation, portrait
No Comments
Add Bottom Shadow In Any Layout Like Cards In Google Now
Posted by blogmeister on
December 13, 2013
Coderwall created a layer list XML drawable in order to achieve this. A big thanks to him! This is how the XML file mydrawable.xml looks like:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle" android:dither="true"> <corners android:radius="2dp" /> <solid android:color="#ccc" /> </shape> </item> <item android:bottom="2dp"> <shape android:shape="rectangle" android:dither="true"> <corners android:radius="2dp" /> <solid android:color="@color/white" /> <padding android:bottom="8dp" android:left="8dp" android:right="8dp" android:top="8dp" /> </shape> </item> </layer-list> |
Make sure you place this in the drawable folder.
To use this, simple set it as the value of the android:background attribute of any layout in your XML.
|
1 2 3 4 5 6 |
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/mydrawable" android:orientation="vertical" > ... </LinearLayout> |
Share the post "Add Bottom Shadow In Any Layout Like Cards In Google Now"












