Android RosImageView match_parent attribute does not work

asked 2014-08-17 06:03:45 -0500

christian.blesing gravatar image

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>

</linearlayout>

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:layout_height="match_parent" attribute has no effect on the views.

Anyone ever had a similar problem or can help me out?

edit retag flag offensive close merge delete

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 an android.widget.ImageView, and does nothing special internally with respect to layout (it just calls setImageBitmap(..) on every new message).

Perhaps a more generic search for issues with laying out an Android ImageView would yield some answers?

gvdhoorn gravatar image gvdhoorn  ( 2014-08-17 06:50:33 -0500 )edit

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.

christian.blesing gravatar image christian.blesing  ( 2014-08-18 01:48:49 -0500 )edit