android - Android多个垂直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 studio 的预览版和设备上,它看起来还不错,但是每当我尝试更改 left 的位置时SeekBar
,就会触发 right 的位置。无论我把拇指放在哪里,唯一正确的都会做出反应。有没有人遇到过这种奇怪的行为?
解决方案
我不知道为什么会发生这种情况(这很奇怪),但我知道如何修复它。不要将 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>
推荐阅读
- hadoop - Hive Beeline 输出 ^M 和空字符
- typescript - 如何在 TypeScript 中为特定类型的泛型类型创建扩展方法
- python - 如何删除除 1 个特定小部件以外的所有子项?
- java - Javassist ; 引起:编译错误:没有这样的类:记录器
- javascript - 如何在 Electron BrowserWindow 中查看 PDF?
- ruby-on-rails - 如何在 ActionMailer 中将云文件添加为电子邮件附件
- php - 获取自定义支付网关数据作为 Woocommerce 3 中的设置
- go - 使用 gocql 将用户定义类型的数组插入 Cassandra
- php - 从用户数据库中获取Referer域的计数
- google-sheets - 将单元格值从 Google 表格链接到 HTML 页面