Android layout qualifier does't work - android

Problem:When I tested my program on different size Android phones, the layout were not selected correctly.
I used setContentView(R.layout.activity_home) to set the layout.
In the res/ directory, I created
res/layout/activity_home.xml
res/layout-sw320dp/activity_home.xml
res/layout-sw480dp/activity_home.xml
res/layout-sw720dp/activity_home.xml
In the AndroidManifest.xml
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:anyDensity="true"
/>
Then I tested it seperately on 320x480,480x800,720x1280 emulators. All these devices selected the layout /res/layout-sw320dp/activity_home.xml.
The target platform I set is 4.4.2 and the emulator's version is 4.3.3.
I have no idea why this happened..

http://developer.android.com/guide/practices/screens_support.html
and
/ here
here
use this link and use the directory structure to support multiple screens
Hope it may help u

Related

Create Android App Support for tablets

I want to create app for support different sizes of tablets, I added this for my Manifest
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
But my app design does not fit for different device screens, I used Android Studio 2.2.2
You need to have several dimen.xml files in values folders such as values-sw600dp, values-sw720dp, values-sw800dp. Next, update values in dimen.xml files(increase or reduce values of dimen items)

Android emulator uses wrong layout resources?

Android emulator uses wrong layout resources ,i'm having a two layout hdpi, mdpi but in emulator get a wrong one why ....
I added in my manifest file ,
<supports-screens
android:anyDensity="true"
android:smallScreens="true"
android:largeScreens="true"
android:normalScreens="true"
/>
In andorid drawable resources usage is depends on ppi.
Please refer the link http://developer.vodafone.com/image-and-graphics-tips-android/
You have to change the emulator ppi values and try your's. Thanks...

Android Multiple Screen Resolutions

I've created a android layout that looks fine on my Galaxy s2 (480×800) device. I want to support a layout for and Galaxy s3 (720x1280) so i created a AVD with those specs, then copied the res/layout directory and contents to two other directories: res/layout, res/layout-large and res/layout-xlarge. To test that the layouts were working positioned a test button at parent-center in res/layout, parent-left in res/layout-large and parent-right in res/layout-xlarge. If i run the application on my device (480×800) or in the AVD (720x1280) the test button is always at parent-center. Why isn't the test button positioned by the values specified in res/layout-large or res/layout-xlarge.
My manifest is as follows:
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" />
<supports-screens
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
I am targeting 2.3.3 and have also cleaned my build before testing
Im seriously going mad so any help would be appreciated.
I don't believe the Galaxy S3 is a "large" screen. Small/normal/large/xlarge refer to physical size, not pixels. You need a combination of screen density and screen size to target different devices. Read the Android guides and training for more details on this.

Android application for Tablet

I have developed an application that is to be run on android Tablet as well. It is working on android phones perfectly. When I ran it on Tablet, it did not expand on whole screen. It just covered a area equal to a mobile device. I want that it also runs on Tablet and cover the whole screen as running on mobile device. Do I have to create two different designs for each type and at run time before using design, I would have to check it whether it is android phone or table?
Add below code in android manifest
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Add the following block of code in your manifest file after the <uses-sdk>tag:
<supports-screens
android:xlargeScreens="true"
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Note: Add the android:xlargeScreens="true" attribute if and only if your minSdkVersion is equal to or more than 9.
In addition to adding this block of code, follow this link. Also suggest you to go through the following links:
Supporting Multiple Screens
Supporting Different Screen Sizes
Supporting Different Densities
Hope this helps.
please try
<uses-sdk android:minSdkVersion="8" android:maxSdkVersion="11"/>
<supports-screens android:anyDensity="true" />
in Manifest.xml before tag.
I hope it may be help you.
Yes, ideally you'll design layouts targeted to tablets. You don't have to, but you can. See here for details. Your app is running in "screen compatibility mode". See here for info about that.
I think you used fixed width and height for any view or layout in your app, to support a fixed resolution of your mobile device.
If you use fill_parent, wrap_content and weight property, such things in your app, the app will fill entire screen of any android device. Once review your code.
Small example
Assume device has no rotation. Your device has resolution 320 X 240. you have to fill 3 buttons horizontally, you can put each button width=100 and remaining as margin/padding of layout. If you run same app on device with resolution 640 X 480, some space will come after 3 buttons. If you use width=fill_parent and layout_weight=1 for these 3 buttons and parent's layout_width=fill_parent, on any resolution these 3 buttons will fill the entire width of screen.
I hope it may help you.

how to work with different resolution in android?

I have to prepare one application.I want give support to different resolution.i have to prepared different layouts.Frist time my layouts is,
res/layout/mylayout----7" normal screen
res/layout-large/mylayout----7" large screen
res/layout-xlarge/mylayout---10.1"
but it is taking 7" large screen.i found some solution in this site.Solution is ,create layout is,
res/layout/mylayout----7" normal screen
res/layout-sw600dp/mylayout----7" large screen
res/layout-sw720/mylayout---10.1"
After changed layout names it is taking 7" large screen only. please help me do.
Check your project Build Target To support xlarge screen your project build target should be atleast android 2.3.3 adk.
In Eclipse -?right click on project -> Properties -> Android -> Select Project Build Tagrget as 2.3.3 or onwards.
First of all set the multiple screen support in your Android Application manifest file
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
And also see this Link
For mulitple screen support Try by using this... in ur android manifest file
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
/>

Categories

Resources