What width of image required to fulfill width of android screen - android

On an android xml file or graphical layout
I want to create an imageview that hold an image.
My question here is what the width of the image in pixels required to fulfill the Android Mobile width.

Since different Android devices have different screen sizes, you won't be able to set an absolute width to fill the screen. You can use android:layout_width="match_parent" as the width for the ImageView and it will resize itself to fit the parent view it's added to.

just write that in xml under ImageView tag
android:layout_width="fill_parent"
thats it

The device width of each android device differs. If you would like to fulfill the image on a device, then it might be streched or truncated on four sides based on the Image width. It would be a nice idea make hte image center, so it looks on all the devices or you might need different sizes of the same image depends on the device widht and height

Related

Button height dynamic

I want to create my button height using drawable xml file and it should also resize dynamically with my layout, so that it can support any Android device.
Currently I am using RelativeLayout with match_parent height. I want to put a set of 3X4 buttons in this layout and should automatically resize with the device height.
I am not able to resize it properly when I use dp values. If I resize the button for large res device, it is not working fine for 240X320 res device.
Yes, you should be able to do what you want with the Android layout classes. You aren't completely clear, but it sounds like GridLayout is what you want.
The default Android UI element should deal well with being sized dynamically; if you have a custom drawable asset, you'll want to make an appropriate 9-patch image at each of the common display densities (so that it not only resizes correctly, but looks good on a range of devices).
I have recently been thinking about this very topic, and I think I can help you. If I understand you correctly, you would like to have your application dynamically resize your buttons depending on the screen size. In order to do that you can use binding and a converter. If you bind your button's height (and width if you prefer) to the page's height (and width) you can use a converter to convert the value to a percentage of the screen size. If you like, I can provide you with some sample code.
You can get the size of the display Display display = getWindowManager().getDefaultDisplay(); and set the sizes dinamically.
Or, you can make various sizes of your images.

Android: make ImageButton's image larger

I have an ImageButton:
I want to make the image (circular play image) bigger. I am aware of android:scaleType, but I don't want to stretch the image all the way to the borders of the button. I just want to make it a little bigger, say 120% of the current size.
Is that possible?
Edit your image in photoshope to make it bigger in your desire resolution.
Or
In android put height , weight of your image and set scaleType:FitCenter
In the xml layout set the width and height to be a larger amount of dip.

In Android, can I change the width of a view inside a widget at runtime

I have a 4x1 widget that holds several ImageView views inside a LinearLayout. I want to be able to have. I want to be able to adjust the width of those views depending on the screen resolution of the device where the app is installed. My goal is to have each view be the same width, and to have them uniformly distributed across the width of the widget. And I'd like it to fill up the whole width of the widget (so that if the widget covers more space on high resolution devices, each ImageView would be wider). I don't want to create different XML layouts for each device type (mdpi, hdpi, xhdpi, etc) -- I'd like to have this done programmatically when the widget is set up (or updated). But I can't find any documentation in RemoteViews that allows me to change the width of a view. So is there a way to do this?
It's not necessary to do it at runtime.
You can use the android:layout_weight tag in your XML file. If you set the weight to 1 and set each image to 0dp, the images will be the exact same width. That way you won't need to create different layouts for each screen size.

Tying images to one another and scaling?

I have an application that needs to scale an image in relation to another image due to different screen size, I have an image that is essentially a background that matches the width of the screen and another image in a relative layout that is aligned so it fits on my phone in 2.2 but when seen on 2.1
Or ... i could just use something that scales the image as a percentage. Suggestions?
edit:
I guess all i need is to know how i can keep an image in a spot relative to another using relative layout and scale it through a percentage, different screen size will scale the other image but not this one because the other image fills the parent so when the screen size is smaller it just scales it down, however the one i need to scale does not because it doesn not fill the parent.

Android Layout Manager scaling images

I am using the Linear Layout Manager and I am trying to use the image width and height (wrapContent) automatically within the application. However, all of the images are appearing larger than what they should be. I think I know why: If I put an image that is 320X480 on the screen, on my device that has a pixel resolution of 480X800, it fills up the entire screen. This results in all of my images being too big for this screen, as I am building my images for a screen size that is 480X800.
Does anyone know how to fix this?
u can use absolute layout!
and can set the width and heigth of the image as u want!
go to the layout xml page and then change it to Absolute layout.
then you can easily change the the width ..
right click -> property
set the height and wigth as u like... Eg:"120dip"
it will solve your issue..
if not let me know will provide you another alternative

Categories

Resources