Android RosImageView match_parent attribute does not work
Hi,
i'm writing an app with andriod-studio and all the ros-java stuff. The app shall display two camera images. I read out the webcams with the uvc_camera node and publish them form my computer to the app. Everything works fine. The images are shown in the app. One image should fill the left half of the screen the other image the right half of the screen. I have used two rosImageViews to do that and put them into a LinearLayout. The Problem is that the rosImageViews don't use the full size of the Smartphone screen. When i start the app the rosImageViews fill out the complete Smartphone screen. But in that moment when both images are displayed the height of the rosImageViews is not correct. The height is then reduced. The width of the views is correct and fills the screen perfectly. Here is my activity.xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
tools:context="${relativePackage}.${activityClass}"
android:orientation="horizontal">
<org.ros.android.view.RosImageView
android:layout_height="match_parent" android:src="@drawable/icon"
android:id="@+id/imageLeft" android:layout_width="305dp">
</org.ros.android.view.RosImageView>
<org.ros.android.view.RosImageView
android:layout_height="match_parent" android:src="@drawable/icon"
android:id="@+id/imageRight" android:layout_width="305dp">
</org.ros.android.view.RosImageView>
Normally the height of the views should match the parent but they don't. The images i read out have the size 640x480 px. It looks like the android:layoutheight="matchparent" attribute has no effect on the views.
Anyone ever had a similar problem or can help me out?
Asked by christian.blesing on 2014-08-17 06:03:45 UTC
Comments
Not really an answer, but:
While
RosImageView
is definitely part of ros android, this seems more of a generic Android layout problem. RosImageView is essentially just anandroid.widget.ImageView
, and does nothing special internally with respect to layout (it just callssetImageBitmap(..)
on every new message).Perhaps a more generic search for issues with laying out an Android ImageView would yield some answers?
Asked by gvdhoorn on 2014-08-17 06:50:33 UTC
I think i have it solved! For the imageView you can set an attribute called "scaleType" in the XML file or in the code. With the right scaleType it should fit the parent perfectly when "match_parent" is used for width and height. I Test it soon and write back if it works.
Asked by christian.blesing on 2014-08-18 01:48:49 UTC