[英]Android multiple vertical seekBars
我正在嘗試為應該有 2 個垂直 SeekBars 的 Android 應用程序設計一個視圖,這是我的 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>
在 android 工作室的預覽版和設備上,它看起來還不錯,但是每當我嘗試更改左側SeekBar
的 position 時,就會觸發右側的。 無論我把拇指放在哪里,唯一正確的都會做出反應。 有沒有人遇到過這種奇怪的行為?
我不知道為什么會發生這種情況(這很奇怪),但我知道如何修復它。 不要將 SeekBars 放在同一個容器中,放在FrameLayout
中就可以了。
<?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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.