miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
03/22/15 01:54 AM (9 years ago)

Android proportional height and width of ImageView

I use Flashcards X plugin in my app which contains images of roadsigns: they should be in same proportion on every Android devices. What I get is this: <a href="https://www.dropbox.com/s/fy4h4o3ac7itjj9/sign_forum.jpg?dl=0" target="_blank" rel="nofollow">https://www.dropbox.com/s/fy4h4o3ac7itjj9/sign_forum.jpg?dl=0</a> with this code in activity_cards.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_activity_root" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout android:id="@+id/main_activity_card_face" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="#ffffff" android:clickable="true" android:onClick="onCardClick" > <ImageView android:id="@+id/card1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignWithParentIfMissing="false" /> </RelativeLayout> Can you tell me what should I change to have roadsigns in right proportions on every Android device?
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
03/22/15 05:26 AM (9 years ago)
Hi @miku, Did you code this? Also did you put the image in the drawable folders? LA
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 07:00 AM (9 years ago)
Android has so many devices to test on ha. What is it suppose to look like?Can you post a picture? On the imageView you can set the height and width to "wrap_content" to have it show the true size of the picture so it wont stretch it out. Then you might center it also
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 07:37 AM (9 years ago)
Images are in drawable folders, this is code in Flashcards X plugin. Road signs should be circle not ellipse, here is how signs look in the same iOS app which works great: https://www.dropbox.com/s/llevbzqzgr7abyg/sign_forum2.jpg?dl=0 I tried also with "wrap_content", but every time image is streched.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 07:48 AM (9 years ago)
I don't own the plugin so I'm not sure. one of the relative layouts are clickable though, so I'm guessing that's the starting picture, then you click it and it shows the other side. If so change that the height and width To wrap_content, and see if that's helps
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 08:53 AM (9 years ago)
I tried it already. so my script is: <ImageView android:id="@+id/card1" android:layout_width="wrap_content" android:layout_height="wrap_content android:layout_alignWithParentIfMissing="false" /> Result: https://www.dropbox.com/s/a9adlrk7rrwkzqv/sign_forum3.jpg?dl=0 My images have same height and width, but here are stretched.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 09:18 AM (9 years ago)
I meant change it on the RelativeLayout <RelativeLayout android:id="@+id/main_activity_card_face" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="#ffffff" android:clickable="true" android:onClick="onCardClick" > are there two images you use? Or when you click on the image it shows the answer?
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 09:36 AM (9 years ago)
I changed in RelativeLayout: android:layout_width="wrap_content" android:layout_height="wrap_content" In use is 1 image, if user clicks on it, it shows answer. All works, only this image problem stops me to finish app.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 09:54 AM (9 years ago)
Which RelativeLayout did you change? What did it do? Usually when image stretches like that it has the fill_parent property
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 09:58 AM (9 years ago)
Also it could be the size of the image.there's a scale property that's something like fitXY that might work
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 10:08 AM (9 years ago)
I can't find where, here is xml file: <ImageView android:id="@+id/card1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignWithParentIfMissing="false" /> <ImageView android:id="@+id/card2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" />
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 10:10 AM (9 years ago)
See that ImageView that has fill_parent came that and see what happens
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 10:28 AM (9 years ago)
If you think: <RelativeLayout android:id="@+id/main_activity_card_back" This is on back side of card, where I don't use any image.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 10:36 AM (9 years ago)
No this ImageView not relative layout <ImageView android:id="@+id/card2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" />
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 10:38 AM (9 years ago)
Match_parent on the other ImageView is same as fill_parent
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 10:53 AM (9 years ago)
Now I changed second ImageView to <ImageView android:id="@+id/card2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerHorizontal="true" Nothing better yet.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 10:56 AM (9 years ago)
To wrap_content instead.match_parent is the same as fill_parent.change it on both imageviews
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 11:06 AM (9 years ago)
First ImageView <ImageView android:id="@+id/card1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignWithParentIfMissing="false" /> Second: <ImageView android:id="@+id/card2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" />
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 11:31 AM (9 years ago)
Yes.what did that do?hopefully it works
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 11:38 AM (9 years ago)
No, result is the same.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 11:41 AM (9 years ago)
Go the the drag and drop part of the xml file and click on the image views.what does it show?
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 11:49 AM (9 years ago)
What is drag and drop part of xml?
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 11:52 AM (9 years ago)
In androud studio or eclipse when you open the layout file there are tabs where you switch between the two? Have you been editing the code in android studio or eclipse?
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 12:03 PM (9 years ago)
Eclipse, you mean graphical Layout? Here is screenshot https://www.dropbox.com/s/emhw3s02yg5447t/sign_forum4.jpg?dl=0, nothing is clickable.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 01:09 PM (9 years ago)
On the right under outline, click those
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 01:39 PM (9 years ago)
Nothing happens, but Accessibilty: missing contentDescription attribute on image is shown.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 01:43 PM (9 years ago)
It should show the outline of it so you know what it will look like.does it fill up the whole screen?
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 02:12 PM (9 years ago)
In case of "wrap_content" outline is not seen (and not clickable), only if I make it "match_parent" back. Then outline fills whole screen.
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 02:19 PM (9 years ago)
Yea match parent is what stretches it out. You should still see it when clicked though. Is there any blue line or something. Can you screenshot when you click it
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 02:26 PM (9 years ago)
Actually under outline after you click ImageView there option to set image.click on the three dots and choose one of the bt images so you can see it
 
miku
Aspiring developer
Profile
Posts: 405
Reg: Feb 20, 2014
zagorje ob savi
10,600
like
03/22/15 02:41 PM (9 years ago)
Which 3 dots? On outline frame?
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 02:55 PM (9 years ago)
Properties.scroll down to src
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
03/22/15 04:27 PM (9 years ago)
have you contacted the developer?we're on 32 posts now ha
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.