Android Development Tutorial
Android powers hundreds of device types with several different screen sizes, ranging from small phones to large TV sets. Therefore, it’s important that you design your application to be compatible with all screen sizes so it’s available to as many users as possible.
But being compatible with different device types is not enough. Each screen size offers different possibilities and challenges for user interaction, so in order to truly satisfy and impress your users, your application must go beyond merely supporting multiple screens: it must optimize the user experience for each screen configuration.
Some More Good Android Topics
Customizing Toast In Android
Showing Toast for Longer Time
Customizing Checkboxes In Android
Customizing Progress Bar
Supporting Multiple Screens
Explicitly declare in the manifest which screen sizes your application supports
By declaring which screen sizes your application supports, you can ensure that only devices with the screens you support can download your application. Declaring support for different screen sizes can also affect how the system draws your application on larger screens—specifically, whether your application runs in screen compatibility mode.
To declare the screen sizes your application supports, you should include the<supports-screens>
element in your manifest file.
Provide different layouts for different screen sizes
By default, Android resizes your application layout to fit the current device screen. In most cases, this works fine. In other cases, your UI might not look as good and might need adjustments for different screen sizes. For example, on a larger screen, you might want to adjust the position and size of some elements to take advantage of the additional screen space, or on a smaller screen, you might need to adjust sizes so that everything can fit on the screen.
The configuration qualifiers you can use to provide size-specific resources aresmall
,normal
,large
, andxlarge
. For example, layouts for an extra large screen should go inlayout-xlarge/
.
Beginning with Android 3.2 (API level 13), the above size groups are deprecated and you should instead use thesw<N>dp
configuration qualifier to define the smallest available width required by your layout resources. For example, if your multi-pane tablet layout requires at least 600dp of screen width, you should place it inlayout-sw600dp/
. Using the new techniques for declaring layout resources is discussed further in the section about Declaring Tablet Layouts for Android 3.2.
Provide different bitmap drawables for different screen densities
By default, Android scales your bitmap drawables (.png
,.jpg
, and.gif
files) and Nine-Patch drawables (.9.png
files) so that they render at the appropriate physical size on each device. For example, if your application provides bitmap drawables only for the baseline, medium screen density (mdpi), then the system scales them up when on a high-density screen, and scales them down when on a low-density screen. This scaling can cause artifacts in the bitmaps. To ensure your bitmaps look their best, you should include alternative versions at different resolutions for different screen densities.
The configuration qualifiers you can use for density-specific resources areldpi
(low),mdpi
(medium),hdpi
(high), andxhdpi
(extra high). For example, bitmaps for high-density screens should go indrawable-hdpi/
.
Note: If you're not familiar with configuration qualifiers and how
the system uses them to apply alternative resources, read Providing
Alternative Resources for more information.
At runtime, the system ensures the best possible display on the current screen with
the following procedure for any given resource:- The system uses the appropriate alternative resource
Based on the size and density of the current screen, the system uses any size- and
density-specific resource provided in your application. For example, if the device has a
high-density screen and the application requests a drawable resource, the system looks for a
drawable resource directory that best matches the device configuration. Depending on the other
alternative resources available, a resource directory with the
hdpi
qualifier (such asdrawable-hdpi/
) might be the best match, so the system uses the drawable resource from this directory.
- If no matching resource is available, the system uses the default resource and scales it up
or down as needed to match the current screen size and density
The "default" resources are those that are not tagged with a configuration qualifier. For
example, the resources in
drawable/
are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate.
Screen characteristic | Qualifier | Description |
---|---|---|
Size | small |
Resources for small size screens. |
normal |
Resources for normal size screens. (This is the baseline size.) | |
large |
Resources for large size screens. | |
xlarge |
Resources for extra large size screens. | |
Density | ldpi |
Resources for low-density (ldpi) screens (~120dpi). |
mdpi |
Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.) | |
hdpi |
Resources for high-density (hdpi) screens (~240dpi). | |
xhdpi |
Resources for extra high-density (xhdpi) screens (~320dpi). | |
nodpi |
Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density. | |
tvdpi |
Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi. | |
Orientation | land |
Resources for screens in the landscape orientation (wide aspect ratio). |
port |
Resources for screens in the portrait orientation (tall aspect ratio). | |
Aspect ratio | long |
Resources for screens that have a significantly taller or wider aspect ratio (when in portrait or landscape orientation, respectively) than the baseline screen configuration. |
notlong |
Resources for use screens that have an aspect ratio that is similar to the baseline screen configuration. |
You need to create different layout for diff screen size. Support all screen you need to create following layout:
.manifest file:
|
Advance Android Topics
Customizing Toast In Android
Showing Toast for Longer Time
Customizing the Display Time of Toast
Using TimePickerDialog and DatePickerDialog In android
Animating A Button In Android
Populating ListView With DataBase
Customizing Checkboxes In Android
Increasin Size of Checkboxes
Android ProgressBar
Designing For Different Screen Sizes
Handling Keyboard Events
More Android Topics:
Android : Introduction
Eclipse Setup for Android Development
Configuring Eclipse for Android DevelopmentBegging With Android
Creating Your First Android ProjectUnderstanding Android Manifest File of your android app
Working With Layouts
Understanding Layouts in AndroidWorking with Linear Layout (With Example)
Nested Linear Layout (With Example)
Table Layout
Frame Layout(With Example)
Absolute Layout
Grid Layout
Activity
Activity In AndroidActivity Life Cycle
Starting Activity For Result
Sending Data from One Activity to Other in Android
Returning Result from Activity
Working With Views
Using Buttons and EditText in AndroidUsing CheckBoxes in Android
Using AutoCompleteTextView in Android
Grid View
Toast
Customizing Toast In AndroidCustomizing the Display Time of Toast
Customizing Toast At Runtime
Adding Image in Toast
Showing Toast for Longer Time
Dialogs In Android
Working With Alert DialogAdding Radio Buttons In Dialog
Adding Check Boxes In Dialog
Creating Customized Dialogs in Android
Adding EditText in Dialog
Creating Dialog To Collect User Input
DatePicker and TimePickerDialog
Using TimePickerDialog and DatePickerDialog In androidWorking With SMS
How to Send SMS in AndroidHow To Receive SMS
Accessing Inbox In Android
ListView:
Populating ListView With DataBaseMenus In Android
Creating Option MenuCreating Context Menu In Android
TelephonyManager
Using Telephony Manager In AndroidWorking With Incoming Calls
How To Handle Incoming Calls in AndroidHow to Forward an Incoming Call In Android
CALL States In Android
Miscellaneous
Notifications In AndroidHow To Vibrate The Android Phone
Sending Email In Android
Opening a webpage In Browser
How to Access PhoneBook In Android
Prompt User Input with an AlertDialog
Storage: Storing Data In Android
Shared Prefferences In Android
SharedPreferences In AndroidFiles: File Handling In Android
Reading and Writing files to Internal StoarageReading and Writing files to SD Card
DataBase : Working With Database
Working With Database in AndroidCreating Table In Android
Inserting, Deleting and Updating Records In Table in Android
How to Create DataBase in Android
Accessing Inbox In Android
No comments:
Post a Comment