question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[SwitchMaterial] On-Off state are not vertically aligned

See original GitHub issue

Description: By using multiple SwitchMaterial components in multiple rows you will see they are not vertically aligned when one of them is on and another is off.

Expected behavior:

I think that thumb of SwitchMaterial should stand in a position (in both on/off) that looks vertically aligned like this image (created by a photo editing app) :

image

Current implementation of SwitchMaterial does not consider vertical alignment as you see:

image

Source code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <com.google.android.material.switchmaterial.SwitchMaterial
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:checked="true" />

    <com.google.android.material.switchmaterial.SwitchMaterial
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="8dp" />

</LinearLayout>

Android API version: 29

Material Library version: 1.1.0

Device: All devices, also in design mode of android studio

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dvruijvencommented, Mar 16, 2021

Hi @angdesign Based on your last update I was wondering if you know any more about when this change might be implemented. I couldn’t spot this on the first alpha for version 1.4.0, so I was wondering if this might be later added to this version or if it will be a bit later down the line for version 1.5.0 or onwards?

2reactions
angdesigncommented, Nov 17, 2020

Following up, acknowledging the staggered effect, and we have an update in the works for Switches to align toggle position to follow the pattern below. unnamed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alignment vertical the switch on Android - Stack Overflow
I am trying to create a layout (Android Studio) in which I need to vertically align various controls like Switch in below screenshot....
Read more >
Switch (On/Off) Tutorial With Example In Android Studio
It is basically an off/on button which indicate the current state of Switch. It is commonly used in selecting on/off in Sound, Bluetooth,...
Read more >
Switch class - material library - Flutter - Dart API docs
Used to toggle the on/off state of a single setting. The switch itself does not maintain any state. Instead, when the state of...
Read more >
Switch | Android Developers
A Switch is a two-state toggle widget. Users can drag the switch "thumb" back and forth to select either of two options or...
Read more >
Switch in Kotlin - GeeksforGeeks
Android Switch is also a two-state user interface element that is used ... android:gravity, Used to specify how to align the text like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found