开发者

Android: MonoDroid: Layout problems, when porting java app to monodroid app

开发者 https://www.devze.com 2023-03-13 17:20 出处:网络
I have a strange layout problem. I developed an app in java and want to port it to C#. Porting the source code is no problem, but the layout is.

I have a strange layout problem. I developed an app in java and want to port it to C#. Porting the source code is no problem, but the layout is. I just copied the contents of my layout.xml(from the java app) into a layout.axml(C# app).

In this layout I define three Framelayouts, three ImageViews, one at the top, another in the middle and the last at the bottom of my view and three buttons, which are placed over the ImageViews.

After running the C# app on the emulator I noticed, that the positions of the imageview开发者_如何学Cs at the top and the bottom are not correct. They have an offset as you can see in the image. The buttons however are correctly positioned.


You should use wrap_content with a underscore not a normal -.


You might want to make sure you are targeting the same version of the Android SDK. I think some layout related stuff changed at some point.


Found the error MonoDroid seems to have a problem, when an imageview has it's layoutheight set to "wrap-content". I changed the layoutheight, just for testing, to 95dp and it worked perfectly. So for everyone encountering layout problems with Monodroid: Try setting layoutwidth/-height to a constant value.

I can not say, if this error also occurs on a real device.

Hope this can help someone

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号