How do i set images for all screen resolution by coding in custom view? not by creating xml
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you make a
LinearLayoutwithfill_parentparameters and fit the image in there, you could accomplish this. Check this question for code examples.As far as “all screen resolutions” goes, Android mostly takes care of that. If you want an image to fill a portion of the width of your screen (perhaps what you mean by “strip”?), then use
fill_parentwidth andwrap_contentheight attributes. Or, if you want the image to fill only half the width of that “strip”, get the device’s width in pixels and divide by 2, i.e.getWindowManager().getDefaultDisplay().getWidth(); / 2, and set theImageView‘s dimensions that way. This will accommodate any Android device since you’re setting different values for the image depending on the device, not hard-coding an arbitrary value for the dimensions, e.g. 100px.Does this cover what you’re trying to ask? Your question isn’t too specific.