Android User Interface Evolution: From Cluttered to Cutting-Edge

 Explain About Android User Interface

Explain About Android User Interface

Introduction to Multiple Screen Size and Orientation Interfaces


Android operates on a wide range of devices that possess varying screen sizes and densities, making it crucial to address multiple screen sizes when designing user interfaces for applications. The following guidelines will assist in achieving support for multiple screen sizes:

Dimensions

Avoid using hardcoded layout sizes.
Utilize dp (density-independent pixels), match_parent, or wrap_content for layout element dimensions.
Use sp (scale-independent pixels) for text size.
Store dimensions in dimens.xml files rather than hardcoding them in the app code or XML files.
Provide dimensions for different screen resolutions in separate values folders:
arduino
Copy code
values-sw720dp    // 10.1” tablet 1280x800 mdpi
values-sw600dp    // 7.0” tablet 1024x600 mdpi
values-sw480dp    // 5.4” 480x854 mdpi, 5.1” 480x800 mdpi
values-xxhdpi     // 5.5" 1080x1920 xxhdpi
values-xxxhdpi    // 5.5" 1440x2560 xxxhdpi
values-xhdpi      // 4.7” 1280x720 xhdpi, 4.65” 1280x720 xhdpi
values-hdpi       // 4.0” 480x800 hdpi, 3.7” 480x854 hdpi
values-mdpi       // 3.2” 320x480 mdpi
values-ldpi       // 3.4” 240x432 ldpi, 3.3” 240x400 ldpi
Considering that the majority of modern phone screen sizes range from 4" to 7", it is recommended to create values folders for xhdpi, xxhdpi, xxxhdpi, sw480dp, and sw600dp, along with a base value folder.

Images and Icons

Provide different images and icons in various drawable folders to cater to different screen resolutions:
arduino
Copy code
drawable-ldpi      // 240x320
drawable-mdpi      // 320x480
drawable-hdpi      // 480x800
drawable-xhdpi     // 720x1280
drawable-xxhdpi    // 1080x1920
drawable-xxxhdpi   // 1440x2560
Avoid applying fixed values to images, as fixed dimensions can lead to distortion on different devices. Instead, use wrap_content.
The recommended minimum size for icons is 32 dp, with 8 dp of space between each icon.
Place app icons in mipmap directories rather than drawable directories. Mipmap directories are retained in the APK even when building density-specific APKs, allowing launcher apps to select the most suitable resolution icon for display on the home screen.

 Layout Design

When developing for Android, it is important to consider different screen sizes and provide appropriate resources. In earlier versions, developers used configuration qualifiers such as small, normal, large, and xlarge to handle this. However, starting from Android 3.2 (API level 13), these size groups have been deprecated, and a new approach using the sw<N>dp (Smallest width device pixel) configuration qualifier is recommended. This qualifier allows you to define the minimum width required by your layout resources.
To create alternative layouts in Android Studio (version 3.0 or higher), follow these steps:

Open your default layout and click on "Orientation in Editor" in the toolbar.
From the drop-down list, select a suggested variant such as "Create Landscape Variant." Alternatively, choose "Create Other" to create a custom variant.
If you select "Create Other," the "Select Resource Directory" dialog will appear. Here, choose a screen qualifier from the left and add it to the "Chosen qualifiers" list. Once you have added all the desired qualifiers, click "OK."
Here's an example of how the layout files could be organized:

res/layout/my_layout.xml # Default layout file
res/layout-ldpi/my_layout.xml
res/layout-mdpi/my_layout.xml
res/layout-hdpi/my_layout.xml
res/layout-xhdpi/my_layout.xml
res/layout-sw480dp/my_layout.xml
res/layout-sw600dp/my_layout.xml
res/layout-sw700dp/my_layout.xml

When designing your layout, it is recommended to utilize LinearLayout and utilize the android:layout_weight attribute appropriately. Instead of creating separate folders for different layouts, strive to create a flexible layout that can adapt well to various screen sizes. By adjusting layout attributes and considering different densities, you can achieve this goal. It is only necessary to provide different images for densities such as hdpi, mdpi, and ldpi, as the Android OS will handle the rest.

If you aim to create a single layout that supports all screen densities, including ldpi, mdpi, hdpi, x-hdpi, and xxhdpi, you can utilize the layout_weight attribute in your layout. This attribute enables effective handling of screen sizes across different devices.


User Interface Classes


In Android, a Layout is utilized to define the user interface for an app or activity and it serves as a container for the UI elements that will be visible to the user.

The user interface in an Android app is created using a collection of View and ViewGroup objects. Typically, Android apps consist of one or more activities, with each activity representing a single screen of the app. These activities contain multiple UI components, which are instances of View and ViewGroup subclasses.

View


The View class represents the fundamental building block for user interface components. A View occupies a rectangular area on the screen and is responsible for rendering and handling events. View serves as the base class for widgets, which are used to create interactive UI components such as buttons, text fields, and more.

Some commonly used Views include:


EditText: A user interface element for entering and modifying text.
ImageView: Displays image resources, such as Bitmap or Drawable resources.
TextView: Presents text to the user.
Button: A user interface element that can be tapped or clicked to perform an action.
ImageButton: Displays a button with an image instead of text, which can be pressed or clicked by the user.
CheckBox: A specific type of two-state button that can be either checked or unchecked.
Spinner: A view that displays one child at a time and allows the user to select among them.

ViewGroup


ViewGroup is a subclass of View and serves as the base class for layouts and layout parameters. It acts as an invisible container to hold other Views or ViewGroups and defines the layout properties.

A group of views is known as a ViewGroup, with the top-level ViewGroup being the parent and all the views and other view groups under it being its children.
ViewGroup
There are several famous ViewGroups used in Android development, including LinearLayout, ConstraintLayout, RelativeLayout, CoordinatorLayout, TableLayout, FrameLayout, WebView, ListView, RecyclerView, and GridView.


                                                      ©Deep99Notes

Post a Comment

Previous Post Next Post