0

In Xamarin.Forms 2.1, at least on Android, setting a control to height match_parent doesn't do anything.

Here is my setup:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="125px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/layoutComment">

    <LinearLayout
        android:id="@+id/layoutTest"
        android:layout_width="20px"
        android:layout_height="100px"
        android:background="@android:color/holo_red_dark"
    >
    </LinearLayout>

    <LinearLayout
        android:layout_toRightOf="@id/layoutTest"
        android:id="@+id/layoutLinesContainer"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:minWidth="50px"
        android:minHeight="50px"
        android:background="@android:color/holo_blue_dark"
    >

That is basically:

- Relative Layout with height wrap_content
  - Linear Layout A with fixed width and height
  - Linear Layout B with a min height/width and match_parent for height

The reason I put a dummy LinearLayout A is to tell the parent that it should at least fit this height.

I expect LinearLayout B to have the same height as its parent or AT LEAST the height of LinearLayout A that came before it or the min height of the parent.

However, LinearLayout B gets height 50px instead which is its min height.

Here is a screenshot:

enter image description here

Red is A and blue is B. B should be the full height of the cell or at least the same as A or the min height of the parent, but instead it uses its min height 50px.

This problem only happens when I used a cell renderer, it doesn't happen if I use a cell without a custom renderer but with its view set to a custom view that has a custom renderer.

My renderer is not doing anything abnormal, it's simply inflating that layout file, setting the provided "convertView" to it then setting the different values.

What should I do? All I want is for LinearLayout B to have the same height as its parent...

SpaceMonkey
  • 4,143
  • 5
  • 38
  • 60
  • 1
    this is pure Android axml, not Xamarin Forms – Jason Apr 04 '16 at 00:11
  • @Jason I'm just about to go to sleep and I had to check what you've suggested... it finally works. Thank you for letting me go to sleep happy after struggling with this the whole day. Reference http://stackoverflow.com/a/19372715/331021 – SpaceMonkey Apr 04 '16 at 00:50

0 Answers0