gpt4 book ai didi

android - 更改 android MediaController 的样式

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:30:01 28 4
gpt4 key购买 nike

有没有办法自定义 MediaController?我需要更改按钮、SeekBar 等的样式。

最佳答案

您可以做的是递归 MediaController 的 View 层次结构并以编程方式设置 SeekBar 的可绘制对象:

private void styleMediaController(View view) {
if (view instanceof MediaController) {
MediaController v = (MediaController) view;
for(int i = 0; i < v.getChildCount(); i++) {
styleMediaController(v.getChildAt(i));
}
} else
if (view instanceof LinearLayout) {
LinearLayout ll = (LinearLayout) view;
for(int i = 0; i < ll.getChildCount(); i++) {
styleMediaController(ll.getChildAt(i));
}
} else if (view instanceof SeekBar) {
((SeekBar) view).setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
((SeekBar) view).setThumb(getResources().getDrawable(R.drawable.progresshandle));
}
}

然后,就打电话

styleMediaController(myMC);

关于android - 更改 android MediaController 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2044000/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com