对于ImageView
显示,我想设置用户可以设置背景颜色和alpha。因此,我保存了首选项后编码如下:
display_tran_seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
@Override
public void onProgressChanged(SeekBar customSeekBar, int progress, boolean fromUser)
{
display_tranI = customSeekBar.getProgress();
tv_display_bgd_vis.setText("Display Invisibility: " + display_tranI + "%");
display.setAlpha( (int) (display_tranI * 255 /100 ));
}
@Override
public void onStartTrackingTouch(SeekBar customSeekBar)
{
}
@Override
public void onStopTrackingTouch(SeekBar customSeekBar)
{
SharedPreferences.Editor e = saved_display_transparency.edit();
e.putInt("saved_display_transparency", display_tranI);
e.apply();
}
});
public void save_display_color(int k)
{
SharedPreferences.Editor e = saved_display.edit();
e.putInt("saved_display", k);
e.apply();
if (k==1) {display.setBackgroundColor(getResources().getColor(R.color.tran_red));}
else if (k==2) {display.setBackgroundColor(getResources().getColor(R.color.tran_orange));}
else if (k==3) {display.setBackgroundColor(getResources().getColor(R.color.tran_yellow));}
else if (k==4) {display.setBackgroundColor(getResources().getColor(R.color.tran_green));}
else if (k==5) {display.setBackgroundColor(getResources().getColor(R.color.tran_blue));}
else if (k==6) {display.setBackgroundColor(getResources().getColor(R.color.tran_purple));}
else if (k==7) {display.setBackgroundColor(getResources().getColor(R.color.tran_pink));}
else if (k==8) {display.setBackgroundColor(getResources().getColor(R.color.tran_brown));}
else if (k==9) {display.setBackgroundColor(getResources().getColor(R.color.tran_black));}
else {display.setBackgroundColor(getResources().getColor(R.color.tran_white));}
}
<RelativeLayout
android:id="@+id/ll_seekbar_display_bgd_vis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btn_display_default"
android:layout_below="@+id/btn_dislay"
android:gravity="center_vertical" >
<SeekBar
android:id="@+id/display_tran_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="18" >
</SeekBar>
可以使用变量display_alpha_integer通过搜索栏调整alpha,该变量正常工作。然而,在用户成功更改backgroundcolor之后,进一步滑动搜索条对显示图像视图没有任何影响。
如何修改上述内容?