0

I have a framelayout that has an imageview and videoview, and the videoview is on the top of the imageview.

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_above="@+id/linearLayout"
    android:layout_centerHorizontal="true">

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/imgFrameId"
        android:background="@android:drawable/sym_def_app_icon"
        android:layout_centerHorizontal="true" />

    <VideoView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/vidFrameId"/>

</FrameLayout>

They are the same size so my videoview covers my imageview, but I don't want that. How can I reduce my videoview's size into 50% (50% of width and height)? I tried many ways but none worked, most will reduce the size to a ratio, I want it to perfectly decrease, like if the original is 500dp, it would be 250dp.

user3549071
  • 117
  • 5

1 Answers1

1

Based on these answers you should extend the VideoView class in a custom class and in the onMeasure method make the changes.

In terms of code this would look like the following :

 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
 int width = widthMeasureSpec/2 ;
 int height = heightMeasureSpec/2 ;

 setMeasuredDimension(width, height);
 }

Let me know if you need more help with this.

Community
  • 1
  • 1
g90
  • 506
  • 3
  • 18