Search code examples
javaandroidseekbarmobile-development

seekbar.setEnabled(false) make seekbar invisible


I have problem with seekbar. I want to make it disable, but when I use .setEnabled(false) function my seekbar disappear. How to avoid this?

My layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackground">

    <SeekBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/seekBar"
        />
</LinearLayout>

My code:

  SeekBar seekBar=(SeekBar) findViewById(R.id.seekBar);
  seekBar.setEnabled(false);

Solution

  • I still dont't know why my seekbar disappear but I find another way to disable a seekBar here: https://stackoverflow.com/a/3278613/4313791