How do I make fully responsive SVGs in an android app - android

I am certain there is a way to make images(probably in SVG format) fully responsive to different screen sizes in an android application, but how is that achieved?
I've tried increasing the width and the height of an ImageView to, let's say, 400dp but it is still static and won't look as big on a tablet.
I am currently trying to make it work with a ConstraintLayout constraints but I can't quite figure it out. It stays centered, but I can't make it bigger.
Please point me in the right direction.

Related

Titanium/ Alloy/ Appcelerator: Cover entire screen with image

I have a JPEG photo which I want to use to as a background for one of the screens.
I want the behaviour to be simlar to the css backgroundSize: cover property. (Play with the following tool to see what I mean: https://davidwalsh.name/demo/background-size.html)
For iPhone, this issue is fairly easy, as you can literally have several different versions of the same image depending which iPhone the app is being installed on.
For Android, this is much more difficult as they have various different aspect ratios and resolutions.
Therefore my question is, how can I specify an image that covers the entire screen.
You can always fake this by adding the imageview inside a View and calculate the proper height/width you need to cover the screen (get the shortest side and scale it up and multiply the other side by the original ratio).
You could also use https://github.com/AndreaVitale/imageview that supports a cover mode
For Android, My suggestion is to use 9-patch Image instead of normal image. It will stretch it self to entire Screen, if you placed image as background
of Window it self as well as worked for ImageView perfectly.
Thank you.

how to make app stretch to all phones android studio

so I'm making a really simple app that just shows some buttons and images,
it looks great on the simulator (because I guess that's the resolution I've been working on ...)
but when I try to build it to my phone it looks differently (the buttons are more stretched out and there is allot more background space in between the buttons and the end of the screen,
I guess it's something that's suppose to be simple but how to I make my app "zoom stretch" to the phone content it's going to be on, meaning it will look the same on any phone and if necessary will stretch the image a bit to fit the screen ?
Thx
In your XML, its important to not use specific(dp,px,etc.) sizes for laying buttons/text boxes/etc. out. For example, for a button thats on the page, use a "layout_width" of "match_parent" and add padding (if necessary from there). This will allow your button to stretch properly without having that extra whitespace.

How can I ensure that my app is compatible with every Android device and will scale views to fit different screen dimensions?

I'm in the beginning stages of developing my first app and wanted to know what I can do from now to make sure my app runs equally well across all Android devices. I don't have access to another device right now to test whether or not it will scale but have I noticed that if I rotate my device to landscape, the items in the view (e.g. buttons, icons) don't scale at all to fit the screen. This makes me worry that it won't be very compatible with other devices.
I find myself putting items in each view by messing with paddings and margins in the XML till I have it right - but now I realise that this makes the layouts specific to my device. Is there a "correct" way of doin this? For instance, if I had to draw 4 horizontal lines equally spaced across the width of a screen how would I achieve this so that the width between the lines are determined according to the size of the screen?
I have a large image in my MainActivity but for some reason it gets really small if I switch to landscape.
Can anybody shed some light on this? Would be really grateful, thanks.
This issue is addressed here:
http://developer.android.com/guide/practices/screens_support.html

Adobe Air Mobile App: Responsive sizing of Elements

I still have trouble understanding the possibilities of Scaling my UI in a responsive way in my Air Mobile App. On the web I'm familiar with it and the use of media-queries.
I dont want to scale my whole UI up and down or even stretch it (e.g: I use the camera in one DisplayObjectContainer, so this would be really bad for the performance to scale this.)
I currently go down the road defining all the container sizes by percent, but that is getting pretty ugly pretty fast as it leaves me with 68.95px values. I think this will get me in trouble one day as blocks appear not crisp anymore. If I round the values, I might have 1px gaps between Elements.
Currently I have this Setup. The idea is, to give every main Component a (maybe invisible) empty background-child. These can then deformed by width & height by any desire. The inner Elements of any Element (button, logo, etc) are not affected by the deformation of the bg and can then be arranged accordingly (as I now have position and size of this container - like in css).
But this does not feel like it is the right way.
Is there a magic lib/class I dont use currently and that allowes me to build in hard pixel for a defined setup and behaves appropriate when it comes to different stageWidths, DPI, etc?
What are your approaches for this problem?

How to make proportional layouts in android?

I have a design that I need to follow in my app. In it there are several buttons, images and textviews placed all over the screen (some are aligned to the left, some to the right, some are centered etc). What I need to do is make all those elements appear EXACTLY as they are in the design image. The problem is, if I try to do this using dp, it can be wider or narrower than the design image specifies, and it depends on the properties of the screen. (I've had an app where I did it all in dp, and on my high-res phone it works perfectly, but on my friend's older phone it cuts away the edges of the activity)
My question is, what elements do I use for this? I've heard of using weight in Linear Layouts, but how to make items different width and height and position them all across the screen how I see fit? How to make sure it looks exactly the same on all screen sizes?
Thanks in advance! :)
Edit:
The point is, I need the buttons to be just as they are on the screen (this will be a listview element, I'm trying to make an xml for it). The distance, proportion, everything, it needs to scale to the width of the screen and be this size and distribution. And, I'm not just looking for a solution to THIS particular problem, I want to learn how to do it in general...
You don't. For very large and very small screens, you use separate layouts that scale the sizes, completely drop parts of the UI, or lays it out in a different manner. It's absolutely silly to think you can fit all the stuff on a 10 inch tablet and a 3.5 inch phone. If your designer expects that, tell him he's an idiot and he needs to get back to work.
For a more general answer on the best way of laying things out- it depends on the effect you're trying to get. You should never use pixel counts, and dp should only be used for small things- a bit of padding between 2 fields. Most things should be done via layout, either by using a linear layout and getting things in rows/columns, or a RelativeLayout and describing how to layout views relative to their siblings. But even with these tools you will not be able to fit on all screens and look good.

Categories

Resources