Mvvmcross: RadioButton's width doesn't use match_parent

Created on 6 Oct 2016  路  3Comments  路  Source: MvvmCross/MvvmCross

I was trying to create border around each of radio buttons, but it wouldn't set its width to match_parent as I specified in XAML. The width would always be set to wrap_content

But if I specify the width in numbers (e.g. 300dp), it works

This is related to the problem mentioned in https://github.com/MvvmCross/MvvmCross/pull/454

Is this behaviour intended?

Steps to reproduce

My RadioGroup

<MvxRadioGroup
        local:MvxBind="ItemsSource OptionList; SelectedItem SelectedOption"
        local:MvxItemTemplate="@layout/radio_button_item"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="20dp"
        android:paddingRight="20dp" />

RadioButtonTemplate (radio_button_item)

<?xml version="1.0" encoding="utf-8"?>
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_marginTop="10dp"
    android:background="@drawable/style_border_item"
    android:paddingLeft="25dp"
    android:paddingTop="25dp"
    android:paddingBottom="25dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    local:MvxBind="Text Value"
    android:text="Test"
    android:textSize="16sp" />

My RadioButton's Background(style_border_item)

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_checked="true">
    <shape android:shape="rectangle">
      <stroke
         android:width="2dp"
         android:color="@color/colorLightGreen" />
    </shape>
  </item>
  <item>
    <shape android:shape="rectangle">
      <stroke
       android:width="2dp"
       android:color="@color/colorGrey" />
    </shape>
  </item>
</selector>

Expected behavior

RadioButton's width should match_parent

Actual behavior

RadioButton's width were wrap_content regarding to each own's text

Configuration

Version: 4.1.0

Platform: Android

android bug

Most helpful comment

This should be fixed whenever someone looks at #1465

All 3 comments

I guess it is because MvxAdapter wraps stuff in MvxListItemView, hence the the width is not respected.

This should be fixed whenever someone looks at #1465

Very great. Thank you!

Was this page helpful?
0 / 5 - 0 ratings