Android 如何暂时禁用 Seekbar?

标签 android android-layout android-seekbar

有没有办法暂时禁用Seekbar? 我尝试了 setEnabled(false) 和 setClickable(false)。它不工作。帮我。 提前致谢。

XML 代码:

<com.devadvance.circularseekbar.CircularSeekBar
        android:id="@+id/circularSeekBar1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        app:lock_enabled="true"
        app:pointer_halo_color_ontouch="#ffd180"
        app:start_angle="150"
        app:end_angle="30"
        app:circle_x_radius="150"
        app:circle_y_radius="140"
        app:use_custom_radii="true"
        app:max="10"
        app:pointer_alpha_ontouch="100"
        app:pointer_color="#ffd180"
        app:circle_stroke_width="3"
        app:pointer_halo_color="#ffd180"
        android:layout_marginLeft="18dp"
        android:layout_marginTop="12dp"
        android:layout_marginRight="18dp"
        android:layout_marginBottom="-25dp"
        android:layout_below="@+id/textView"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

在 JAVA 代码中:

CircularSeekBar seekbar = (CircularSeekBar) findViewById(R.id.circularSeekBar1);
    seekbar.setAlpha(0.45f);
    seekbar.setEnabled(false);

最佳答案

我找到了暂时禁用搜索栏的答案。

在 Xml 中,只需创建一个可见性的布局:GONE

<LinearLayout
                        android:id="@+id/Mainlayout"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent">
     <LinearLayout
                        android:id="@+id/seekbarblocklayout"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:orientation="vertical"
                        android:clickable="true"
                        android:visibility="gone"
                        />
    <com.devadvance.circularseekbar.CircularSeekBar
            android:id="@+id/circularSeekBar1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
    ....
    ....
    />

</LinearLayout>

在 Java 中,

    public void disableSeekbar{

             seekbarblocklayout=(LinearLayout)findViewById(R.id.seekbarblocklayout);
            seekbarblocklayout.setVisibility(LinearLayout.VISIBLE);
            seekbarblocklayout.bringToFront();
    }

  public void enableSeekbar{
            seekbarblocklayout.setVisibility(LinearLayout.GONE);
    }

关于Android 如何暂时禁用 Seekbar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31875251/

相关文章:

android - Button.setCompoundDrawablesWithIntrinsicBounds() 的左/右填充?

android - 为什么drawablePadding在Button中不起作用?

java - 根据 Android Intent ACTION_SEND 中的选择更改收件人电子邮件 ID

android - 如何使用搜索栏设置时间范围

android - 布置底部对齐的按钮

java - 以编程方式在android Edittext中获取提示文本值

android - 具有多个布局的 ListView 在滚动时崩溃

android - Seekbar 缩略图剪辑

android - 如何实现价格范围搜索栏?

java.lang.OutOfMemory错误: Failed to allocate a 36000012 byte allocation with 16777216 free bytes and 21MB until OOM