我正在尝试在不使用setProgressTintList方法的情况下更改Progress Bar色调,因为此方法需要API 21.
例如,单击按钮应在这两种模式之间切换:
我的代码:
int[][] states = new int[][] {
new int[] { android.R.attr.state_enabled}, // enabled
new int[] {-android.R.attr.state_enabled}, // disabled
new int[] {-android.R.attr.state_checked}, // unchecked
new int[] { android.R.attr.state_pressed} // pressed
};
int[] colors = new int[] {
getResources().getColor(R.color.my_color),
getResources().getColor(R.color.my_color),
getResources().getColor(R.color.my_color),
getResources().getColor(R.color.my_color)
};
ColorStateList myList = new ColorStateList(states, colors);
ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.recording_progress);
simpleProgressBar.setProgressTintList(myList);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1309 次 |
| 最近记录: |