不需要Seekbar焦点

问题描述 投票:2回答:5

我在布局中使用SeekBar,并且有另一个视图是RelativeLayout。

<CoordinatorLayout>

    <RelativeLayout>
    ...
    </RelativeLayout>

    <SeekBar
        android:id="@+id/progressSeekBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:progress="70"
        android:progressDrawable="@drawable/player_seek_bar_progress"/>

</CoordinatorLayout>

当我触摸此RelativeLayout时,SeekBar会获得焦点...即使在我的代码中,我在布局中也没有发现任何问题...

有人遇到同样的问题吗?

感谢大家的回答:)

android android-seekbar
5个回答
4
投票

我刚刚遇到了完全相同的问题。我的布局类似于以下内容(我省略了与该主题无关的视图)。如您所见,父视图(LinearLayout)和SeekBar都具有android:clickable="true"属性。


0
投票
<SeekBar
    android:id="@+id/progressSeekBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:progress="70"
    android:progressDrawable="@drawable/player_seek_bar_progress"
    android:focusable="false"/>

0
投票
mSeekBar = (SeekBar) v.findViewById(R.id.progressSeekBar);
mSeekBar.setFocusable(false);

0
投票

只需将其放在根视图中并删除根中所有可点击的对象


0
投票

只需将android:clickable="true"android:focusable="true"设置为SeekBar XML属性。这样做之后,当您单击父布局时,SeekBar将不会获得焦点。

© www.soinside.com 2019 - 2024. All rights reserved.