I'm trying to design a view for Android app that is supposed to have 2 vertical SeekBars, here's my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/control_view_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="#0099cc"
android:orientation="horizontal"
tools:context=".FullscreenActivity">
<SeekBar
android:id="@+id/seekBarL"
android:rotation="270"
android:splitTrack="false"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<SeekBar
android:id="@+id/seekBarR"
android:rotation="270"
android:splitTrack="false"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
In the android studio's preview and on a device it looks just fine, but whenever I try to change the position of the left SeekBar
, the right one gets triggered instead. No matter where I put my thumb on, the only right one reacts. Does anyone ever get this strange behavior?
I don't know why this happens (it is strange) but I know how to repair it. Don't put SeekBars in the same container, put it in FrameLayout
and it will work.
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/control_view_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<SeekBar
android:id="@+id/seekBarR"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotation="270" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<SeekBar
android:id="@+id/seekBarL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotation="270" />
</FrameLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.