繁体   English   中英

Android 多个垂直seekBars

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM