#StackBounty: #java #performance #android #error-handling #generics Custom MediaController with full screen video image option

Bounty: 150

I have overridden setAnchorView() of MediaController class to display full screen option icon using below code.The code seems to be working fine in devices I tested but I have few doubts for which I need review-

  • The class assumes the anchor view is a FrameLayout to position full
    screen imageview.
  • Should I use try catch inside setAnchorView?

public class FullScreenMediaController extends MediaController {

    private final Boolean isFullScreen;
    private final Listener listener;

    public FullScreenMediaController(Context context, Listener listener, Boolean isFullScreen) {
        this.listener = listener;
        this.isFullScreen = isFullScreen;

    public void setAnchorView(View view) {


        //image view for full screen to be added to media controller
        ImageView fullScreen = new ImageView(super.getContext());

        FrameLayout.LayoutParams params =
                new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
        params.gravity = Gravity.RIGHT;
        params.rightMargin = 50;
        params.topMargin = 20;
        fullScreen.setPadding(10, 10, 10, 10);
        addView(fullScreen, params);

        if (isFullScreen) {
        } else {

        //add listener to image view to handle full screen and exit full screen events
        fullScreen.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {

    public interface Listener {
        void onFullScreenClick();

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.