1

I found the following post on SO regarding constraint layout flow helpers ConstraintLayout Flow helper example and wondered if they could be used with radio buttons.

I can find little about using flow helpers anywhere.

I tried adding the following to my layout inside the RadioGroup.

    <androidx.constraintlayout.helper.widget.Flow
        android:id="@+id/flow1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:padding="10dp"
        app:constraint_referenced_ids="radioButton, radioButton2, radioButton3"
        app:flow_horizontalBias="0"
        app:flow_horizontalGap="10dp"
        app:flow_horizontalStyle="packed"
        app:flow_verticalBias="0"
        app:flow_wrapMode="chain"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

When I try to run the app I get the following errors:

Android resource linking failed
C:\AndroidProjects\MyApp\app\src\main\res\layout\activity_main.xml:158: error: attribute flow_horizontalBias (aka com.domain.myapp:flow_horizontalBias) not found.
C:\AndroidProjects\MyApp\app\src\main\res\layout\activity_main.xml:158: error: attribute flow_horizontalGap (aka com.domain.myapp:flow_horizontalGap) not found.
C:\AndroidProjects\MyApp\app\src\main\res\layout\activity_main.xml:158: error: attribute flow_horizontalStyle (aka com.domain.myapp:flow_horizontalStyle) not found.
C:\AndroidProjects\MyApp\app\src\main\res\layout\activity_main.xml:158: error: attribute flow_verticalBias (aka com.domain.myapp:flow_verticalBias) not found.
C:\AndroidProjects\MyApp\app\src\main\res\layout\activity_main.xml:158: error: attribute flow_wrapMode (aka com.domain.myapp:flow_wrapMode) not found.
error: failed linking file resources.
Greum
  • 81
  • 1
  • 5

2 Answers2

2

Use constraintlayout:2.0.0-alpha5 in gradle

Refer Flow

  • Thanks. That gets rid of the errors. It doesn't seem to wrap the radio buttons, so I'm not sure if that means I can't use Flow with radio buttons or there's something else I need to do with my layout file. – Greum Jul 10 '19 at 12:23
1

Yes, you can use ConstraintLayout (and Flow) to arrange RadioButton, but you have to use a ConstraintLayout aware RadioGroup widget to manage RadioButton widgets.

Please visit https://github.com/samlu/ConstraintRadioGroup. The blRadioGroup widget should be what you are looking for.

Sam Lu
  • 3,448
  • 1
  • 27
  • 39