Android XML layout Design for various screens - android-layout

Recently I have to develop a simple app for my company with UI which has to look alike in different set of screens. I was provided only one set of drawable-resources.
I have gone through the android developer.
In the link, they showed an example which divided the drawable folder into based on density and layoput folder based in sizes.
Since I had only one set of images, Can I divide the screen based on density like
layout-ldpi
layout-mdpi
layout-hdpi
layout-xhdpi
Can I do it in this manner? And how far is it reliable?

u should create drawable folders for all layout designs. it automatically takes the respective drawable folder for respectve density.
res/drawable-ldpi
res/drawable-mdpi
res/drawable-hdpi
res/drawable-xhdpi
so on..
mdpi is the base, means u first add images in ur mdpi folder and then convert images for others drawables
check this too: same for drawable and values
res/layout-sw320dp-ldpi
res/layout-sw320dp-mdpi
res/layout-sw320dp-hdpi
res/layout-sw320dp-xhdpi and so on..
res/layout-sw480dp-ldpi
res/layout-sw480dp-mdpi
res/layout-sw480dp-hdpi
res/layout-sw480dp-xhdpi and so on..
res/layout-sw600dp-ldpi
res/layout-sw600dp-mdpi
res/layout-sw600dp-hdpi
res/layout-sw600dp-xhdpi and so on..
res/layout-sw720dp-ldpi
res/layout-sw720dp-mdpi
res/layout-sw720dp-hdpi
res/layout-sw720dp-xhdpi and so on..
more info:
Different resolution support android
Application Skeleton to support multiple screen
Is there a list of screen resolutions for all Android based phones and tablets?

Related

Flutter image assets for landscape

Following this doc:
https://docs.flutter.dev/development/ui/assets-and-images
I know how to declare resolution aware images in assets using asset variants.
The problem I have is that I need to use different images based on orientation.
I have a background image that is different on portrait & landscape. I know I can do it in code but was hopping there is an asset variant for this?
Thanks!

AgoraKit - How to create a grid style video session layout?

I'm using Agora sdk for video calling feature in my app. I've tried the advance iOS example, and currently able to see the video call between two users.
However my UI needs to show it in grid layout of same size items (maximum 8 video call views)... Like a vertical UICollectionView of equal sized cells. (screenshot below)
I've tried the Advanced video example from here - https://github.com/AgoraIO/Advanced-Video but couldn't figure out how to make the grids.
Kindly guide me how to do this. Thanks.
I have a small demo that creates NxN grids of all the video feeds in a chat in this example.
https://github.com/maxxfrazer/Agora-iOS-Swift-Example/blob/248a1d2291060891f2fda92a657c2067d841d964/Agora-iOS-Example/ChannelViewController%2BVideoControl.swift#L108
it just leaves black holes where the other ones should be if there's not a square number of people in the chat, but hopefully it is enough to get you started with repositioning views based on the number of connected users.

Android ImageView place other image and text in region

I am trying to setup a layout such that it has an image with regions. Those regions,can have either other ImageView or TextView. I am able to achieve this at a high level using FrameLayout and RelativeLayout. However, it does not scale properly on different devices.
As an example here is an image
Yellow/Red Region - ImageView setup dynamically
Blue/Green Region - TextView
So On the Device, I want it to look like this:
And like this:
Note that Image scales correctly and so does child views in correct regions.
Can someone please share some ideas on how this could be achieved?
I was able to do this by writing a Custom View. I set the layout bonds based on the % offset.
For example the image would start at 15% off top and 10% off left and width is 30% card size etc.
I tested this with multiple devices and so far it is working as designed.
Have a look at Supporting Different Screen Sizes
Also have a look at Supporting Multiple Screens
This links has exactly what you are looking for. Follow the example and you will achieve the desired result.
These tutorials explains how to scale images based on the screen sizes and how to design your layout.
Extract from Google's dev site:-
Explicitly declare in the manifest which screen sizes your application supports
Provide different layouts for different screen sizes
Provide different bitmap drawables for different screen densities
Use OnConfigurationChanged() to determine the orientation and changes the views according to your requirements
public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
{
if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){
//Change the Layout width and height attributes according to your requirements
Log.e("On Config Change","LANDSCAPE");
}else{
//Change the Layout width and height attributes according to your requirements
Log.e("On Config Change","PORTRAIT");
}
base.OnConfigurationChanged(newConfig);
}

Images in J2me Lwuit

I have developed an LWUIT app. I have two types of images dispayed in the app. One coming from server side that need to displayed (like a photo posted and saved to server side) and one packaged in my jar and displayed mainly as icons (like a music icon, loading animation gif etc). I need to display all images according to the sreen size and resolution. The first kind is displayed by taking the screen display height and width and then use scale method and show a scaled version of the image. But however I have no idea how to show the second kind. i.e. icons. Example, my loading image looks good in most of the phones but for some phones like samsung, it looks blurred and over-sized. How to do this. My basic idea is to keep 3 types of images of icons like icon_width_lowXheight_low.png, icon_width_mediumXheight_medium.png and image_width_highXheight_high.png and show it based on the screen size. Please let me know the bets way to achieve this?
Thanks,
Parvathy
You should use MultiImages which were added in LWUIT 1.5. I don't have a link for this in LWUIT but our work in Codename One is pretty close to this so check out the How Do I? on multi images (and I suggest migration to Codename One regardless).
I think that you will need to use this
Image i = Image.createImage("your image path here");
i = i.scaled(widthValue, heightValue);
And put this values in relation to the Display.getInstance().getDisplayHeight() and Display.getInstance().getDisplayWidth()
Right?

How to create Android Google Play's Grid View like Widget with different size images loaded dynamically

Hi
I have enclosed two app images which has grid view like widgets with different image heights and widths, loaded dynamically ,i need to create the same type of UI ,i could be glad if someone guide me to start with.
A similar question was asked previously and this is the answer.
The developer used Bucket List Adapter to create the google play like list view.

Resources