2

I want to set fullscreen in VideoView which is child of ViewFlipper and added programmatically but it does not set as a screen size and it always set as its resolution. I used relative layout out though.

Here is some snippet

viewFlipper.xml

<ViewFlipper
        android:id="@+id/viewflipperSlideShow"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:autoStart="true"
        android:flipInterval="2000"/>

Here is code

            VideoView postVideoView;
            postVideoView = new VideoView(PostSlideShowActivity.this);

            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            postVideoView.setLayoutParams(layoutParams);

            Uri uri = Uri.parse(imageURL);
            postVideoView.setVideoURI(uri);
            postVideoView.setTag(TAG_VIDEO);

            viewFlipper.addView(postVideoView);
Kuls
  • 2,047
  • 21
  • 39
  • 1
    ViewFlipper extends FrameLayout, use `FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);` – Eugen Pechanec Aug 02 '16 at 11:41
  • 1
    Thanks @EugenPechanec but it ain't worked. I've used this `FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); postVideoView.setLayoutParams(frameLayoutParams);` – Kuls Aug 02 '16 at 11:57
  • 1
    Are you looking for this? http://stackoverflow.com/questions/19601921/center-crop-an-android-videoview – Eugen Pechanec Aug 02 '16 at 12:10
  • 1
    I want same functionality of `imageView.setScaleType(ImageView.ScaleType.FIT_XY);` for `VideoView` where i can Scale my `VideoView` to total dimension of my mobile screen. But by above code `VIdeoView` is not set to the entire screen. @EugenPechanec – Kuls Aug 02 '16 at 12:14
  • 1
    fit_xy does not preserve aspect ratio, it's going to be stretched. Usually not something you want with video. It can probably be done by adapting what's done in the link above. – Eugen Pechanec Aug 02 '16 at 12:16
  • Sorry but it didn't help me. I just tried.. Thanks @EugenPechanec – Kuls Aug 02 '16 at 12:37

0 Answers0