有没有办法暂时禁用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/