themed-toggle-button-group
themed-toggle-button-group copied to clipboard
Button's strange size
The code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<nl.bryanderidder.themedtogglebuttongroup.ThemedToggleButtonGroup
android:id="@+id/days"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:justifyContent="center"> <!-- this attribute is from the underlying FlexboxLayout -->
<nl.bryanderidder.themedtogglebuttongroup.ThemedButton
android:id="@+id/monday"
android:layout_width="wrap_content"
android:layout_height="38dp"
app:toggle_text="Lunedì"
app:toggle_selectedBackgroundColor="@color/primary_color"/>
<nl.bryanderidder.themedtogglebuttongroup.ThemedButton
android:id="@+id/tuesday"
android:layout_width="wrap_content"
android:layout_height="38dp"
app:toggle_text="Martedì"
app:toggle_selectedBackgroundColor="@color/primary_color"/>
/>
<nl.bryanderidder.themedtogglebuttongroup.ThemedButton
android:id="@+id/wednesday"
android:layout_width="wrap_content"
android:layout_height="38dp"
app:toggle_text="Mercoledì"
app:toggle_selectedBackgroundColor="@color/primary_color"/>
/>
<nl.bryanderidder.themedtogglebuttongroup.ThemedButton
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="38dp"
app:toggle_text="Giovedì"
app:toggle_selectedBackgroundColor="@color/primary_color"/>
/>
</nl.bryanderidder.themedtogglebuttongroup.ThemedToggleButtonGroup>
</LinearLayout>
Screenshots
Only when I select a button it shows correctly.
I cannot reproduce this. Have you tested this with just the code you shared? It seems the height is only set on the inactive buttons.
I also encountered this bug. It always happened when views get switched, like in a tabbed layout. I used a ViewModel to resolve this issue.