or create your own resource using the bool value (from google io 2012)
<resources> <bool name="small_screen">true</bool> <bool name="normal_screen">false</bool> </resources> <resources> <bool name="small_screen">false</bool> <bool name="normal_screen">true</bool> </resources>
NOTE. You must define the minimum screen width (sw320dp) for which you think the screen is not small ( link with additional information )
The advantage is that you can read this value at runtime, and you can have special cases for special resource qualifiers ... for example. you can read this value at runtime by invoking your activity:
if(getResources().getBoolean(R.bool.small_screen)) {
You can even use this logical resource in your manifest to start a completely different action for small screens
<activity android:name="SmallScreenActivity" android:enabled="@bool/small_screen"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="NormalActivity" android:enabled="@bool/normal_screen"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
This way you can just use Activity for the normal case (android: enabled = "@ bool / normal_screen") and use special activity for the small screen android: enabled = "@ bool / small_screen"
A WARNING. This method will not work on newer devices since cellular. You can read why this method is no longer allowed or read about working with a similar solution.
Entreco
source share