last day (14 days later) » 

11:11 AM
0
Q: keep aspect ratio of background image (android)

vtnii have a background image which should be scaled on the height, but keep its aspect ratio. i tried it whith this code: <ImageView android:id="@+id/iv_background" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop...

 
have you tried removing android:scaleType="centerCrop"
 
yes, then it doesnt work on phones in potrait mode
 
Could you show us some screens?
 
What do you want to do exactly? Because it's working as intended on my tablet. the image will always be cut unless you display white stripes on top/bottom or left/right
 
11:11 AM
i imagined it like this: abload.de/img/bgjdi4m.jpg it should only cut the sides, but in the avd tablet emulator it cuts top and bottom.
 
Here is a print of my tablet. dropbox.com/s/prnj8gutcgz1ddl/… As you can see. Nothing cut.
 
on your tablet, it also cuts the top and bottom of the image
 
But that's the actionbar and the system bar. That's what is supposed to happen.
You there?
 
but i think it cuts more than the width of the action bar
 
Do you wan't to show the actionbar?
 
11:18 AM
and also in the tablet the width fits, on the phone the height
in some cases, yes
 
my bg isnt great, you can try it and make some red dots on top and bottom
the bubble on the right side (top) isnt on your background rivello.net/img/bg.jpg
 
That's because the ratio of the image isn't the same. I don't think that what you're trying to achieve is possible
 
11:35 AM
ok, then i have to avoid landscape mode on tablets
i have another question, if you know this: i tried to place some icons with variable marginLeft (percentage). i tried it with dp, but on tablet it isn't really relative. is there a trick or sth?
 
Not really. You can use diferent value folders with diferent xml's for diferente screen sizes
 
so i cannot set the margin to 30% of the display width?
 
No. What you can do is to build your layout around weights since them use percentage
 
you mean LinearLayout and layout_weight?
 
11:44 AM
ok i will try this
thank you
 

last day (14 days later) »