【发布时间】:2018-07-19 13:42:14
【问题描述】:
我有点困惑。 我有这个:
this.opacitySeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
// updating opacity of layout
RelativeLayout ledColor;
for(int index = 0; index < selectedLedsIndices.size(); index++) {
ledColor = (RelativeLayout)ledsLayout.getChildAt(index).findViewById(R.id.led_color);
ledColor.setAlpha(((float)i) / 255);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
我正在尝试使用搜索栏的进度值更改布局的不透明度。 seekbar 的值从 à 变为 255。但是在运行时,布局的不透明度不会改变。我没有得到任何错误跟踪。它只是不想改变。怎么样?
我在 api 24 上运行应用程序(我的应用程序应该以 19 到 27 的 api 为目标)。
【问题讨论】:
-
什么是
ledsLayout,什么是ledColor?发布您的 xml 并明确您想要更改其 alpha 的布局以及您如何访问它。
标签: android android-layout alpha android-seekbar