1
如何以编程方式更改MediaController
图标?我的意思是播放/暂停/转发和rew。以编程方式更改MediaController图标
你看,我已经加入全屏按钮,但不能认识到如何改变这三个。
定制的MediaController类:
public class CustomVideoController extends MediaController {
public static boolean full = false;
private ImageButton fullScreenBtn;
Context mContext;
Activity activity;
VideoView mVideoView;
public CustomVideoController(Context context, Activity activity, VideoView videoView) {
super(new ContextThemeWrapper(context, R.style.VideoPlayerTheme));
this.activity = activity;
mContext = context;
mVideoView = videoView;
}
@Override
public void setAnchorView(View view) {
super.setAnchorView(view);
FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
frameParams.gravity = Gravity.RIGHT | Gravity.TOP;
frameParams.setMargins(12,14,10,12);
View v = AddFullScreenBtn();
addView(v, frameParams);
}
@Override
public void hide() {
super.hide();
}
@Override
public void show(int timeout) {
super.show(0);
}
private View AddFullScreenBtn() {
fullScreenBtn = new ImageButton(mContext);
if (full)
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_stretch);
else
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_shrink);
fullScreenBtn.setBackgroundColor(Color.WHITE);
fullScreenBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (full){
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_stretch);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
full = false;
} else {
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_shrink);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
full = true;
}
}
});
return fullScreenBtn;
}
请帮我更改这些图标绘项目。它有可能吗?我真的很困惑那个。
但是有没有一种方法来欺骗或应用自定义布局? – AnZ 2015-04-03 10:43:42
@AnZ我不这么认为。这是一个随时可用的小部件,因此无法像这样修改它,但是您可以看看它是如何完成的并实现完全自己的MediaController – 2015-04-03 11:03:14
,并且如果我在SDK中替换图标? – AnZ 2015-04-04 12:34:32