How to set height and width of videoview in android

Forums Search forums. New posts What's new New profile posts Latest activity. Members Current visitors New profile posts Search profile posts. Log in Register. What's new. Search forums. Log in.

Spectrogram matlab source code

For a better experience, please enable JavaScript in your browser before proceeding. Thread starter ronovar Start date Apr 12, I im using videoview to play video file AddView VideoView1, 0, 0, pnlVideo.

Width, pnlVideo.

Sarpanch mobile number mp

Yes i im using this library and it works fine So i think i need to set in manifest editor RelativeLayout Then VideoView will be scalled all video aspect ratio to I can't use VideoViewRelativeLayout library because then i can't switch from small screen to full screen. SetLayout properties od VideoView1 is working perfectly for small screen, full screen. Thanks for info Then using javaobject call it will be easy to add to b4a.

Interesting is when adding relativelayout it centeres and it is full screen Sorry about that. However, still, it should be possible to extend and add scaling-options to the original VideoView-class.

When I find some time, I will have a look In the meantime, you can probably use the XmlLayoutBuilder library to obtain what you want. Thank you for replay I am sorry but I have never used it myself so I guess you will need to try and experiment a bit and see if you can obtain what you want. If I recall correctly, another user had the same or similar requirement as you and we discussed it in the FFMpeg-B4A wrapper thread. RemoveView Activity. Last edited: Apr 13, Ok i found solution but need help using javaobject B4X:.

I don't think you can access the method "onMeasure" because it's an override of the original method in the super-class SurfaceView and I think you need that method. What regards the method "setMeasuredDimension", it should be part of android. It seems complicated but I may be wrong though Maybe it can be done with inline java? Note: I edited my reply.

View setMeasuredDimension function. If Erel or other skilled forum member can write here how to call setMeasuredDimension in android. View to set Width and Height using javaobject or reflector it will be great. I have successfully read video width and height using code above, just need setMeasuredDimension function to set it up or update it to AddView. Load video that is ratio and image is not full screen on 16;9 it is full screen B4X:.I am using android gridview in Xmarine c project.

Orientation; if LayoutOrientation! LinLay ; Lin. GridMiddle ; GVMiddle. NightFury said: I have tried you scenario then i got following exception. GridMiddle. Xamarin Inc. This site uses cookies for analytics, personalized content and ads.

How to set View width (height) in percentage of parent View in Android

By continuing to browse this site, you agree to this use. Learn more. Xamarin Menu About What is Xamarin? What is Xamarin. August edited August in Xamarin.

how to set height and width of videoview in android

How to do this? Tagged: android layout android design xmarine Xamarin Android Activity. Best Answers. August edited August Accepted Answer. Lets give try for it and let me know its working or not. August Accepted Answer. NightFury said: I have tried you scenario then i got following exception android app actionbar layoutparams cannot be cast to android widget linearlayout layoutparams as per my opinion your trying to modify LayoutParams of child view which is your GridView which have parent layout like Linear or Relative or Something else.

August edited August By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I have created a custom view named Graphview. Here is the structure for the GraphView class. I have added the view in a tablerow using addview. It is working fine. Now I want to set height and width for the GraphView. How to do that?

This is fine if you know the exact size of the view. You can find an example on how to override onMeasure by looking at the android docs and the LabelView sample in your SDK directory. This is a Kotlin based version, assuming that the parent view is an instance of LinearLayout.

This allows to set the width and height and in a single line.

Slap dee bangeli baliko mp3 download

How are we doing? Please help us improve Stack Overflow. Take our short survey. Learn more. Android set height and width of Custom view programmatically Ask Question. Asked 9 years, 1 month ago. Active 5 months ago. Viewed k times. Akram 7, 7 7 gold badges 42 42 silver badges 70 70 bronze badges.

Active Oldest Votes. The easy way is to set the size programatically like that : graphView. Dalmas Dalmas GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Already on GitHub? Sign in to your account.

Subscribe to RSS

Right now in sample project FrameLayout height is dp. Can you add this in your library itself or please let me know how can I do my self! If you dont know the size and wanna use the video size, then u may need to wait for OnPreparedListener callback to get the video size. So do something like the following in onPrepared. However, I believe this is not good practice as an item of recyclerview since u need to wait some time to get the size of video.

how to set height and width of videoview in android

This causes non-smooth scroll. Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up. New issue. Jump to bottom. Copy link Quote reply.

This comment has been minimized. Sign in to view. Still, thank you for some solution. Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment. Linked pull requests.

Subscribe to RSS

You signed in with another tab or window. Reload to refresh your session.

Nest error codes

You signed out in another tab or window.Android VideoView class is used to display Video files in them. Following are the acceptable formats:. VideoViews can play videos either from resource files, local data or url specified.

how to set height and width of videoview in android

Following are some of the methods used on VideoView:. For having media control inside the video, we need to set the onPreparedListener on our VideoView and then set the anchor inside it. This way the MediaController is set inside the VideoView. It should be done to prevent memory leaks. Now the output of the above application in action is given below:.

This brings an end to android video view tutorial. You can download the final Android VideoView project from the link below. Thanks for example. This video player is not showing volume controller. Can you explain how to add that. Your email address will not be published. I would love to connect with you personally. Table of Contents 1 Android VideoView 1. Android Studio VideoView Project. Shoot him queries. Follow Author. Comments Manish says:. February 6, at pm. Leave a Reply Cancel reply Your email address will not be published.

Leave this field empty.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. But the VideoView matches the width of the parent container, and then the height is set according to the aspect ratio of the loaded movie.

how to set height and width of videoview in android

I would like to do just the opposite, I want the VideoView to match the height of the parent while keeping the aspect ratio intact, the video will be clipped on the sides. This works great, and the controllers always stay on, but the height of the controllers is not being taken into account when calculating where to place the video since it's vertically centered.

Call setVideoSize before video view is shown, you can get video size from thumbnail extracted from video. If you want to account the height of controllers, you can do it yourself in the onMeasure method. I solved this problem with layout. It seems that it worked fine when it was pinned to the corners but it caused the video to skew. To test I changed my relative layout's background to to see the red poking through.

Regarding question 1, I am surprised no one has mentioned the possible use of the MediaPlayer's scaling mode. It has 2 modes. Both of them always fill the view area. That solves one part of the problem.

The other part is to change VideoView's measuring behavior, just as some of the other answers demonstrate. This is the way I did it, mostly out of laziness and not familiar with the metadata API's that the others use, you are welcome to use this method or one of the other methods to fix the size of the view.

The blanket catch ensures safety when this is called before mMediaPlayer exists, as it may be called many times, and also falls back to old behavior should the field name ever change. So using this class in the layout, you just change the scaling mode on the media Player wherever you have a chance. Such as:. No need to create a custom view extending from VideoView.

This will set the widthSpecMode of the video view to View.

Avengers fanfiction peter and doctor strange

For the first time a question answered my issue instead of answers!! My issue was that I had a white space under the video on full screen. That, and having the VideoView centered vertically in its parent. I wrote this as a comment but then thought someone might have the same issue I had, so here it is as an answer also.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I have created a custom view named Graphview. Here is the structure for the GraphView class.

I have added the view in a tablerow using addview. It is working fine. Now I want to set height and width for the GraphView. How to do that? This is fine if you know the exact size of the view. You can find an example on how to override onMeasure by looking at the android docs and the LabelView sample in your SDK directory. This is a Kotlin based version, assuming that the parent view is an instance of LinearLayout.

This allows to set the width and height and in a single line. Learn more.

How to set android:layout_width and android:layout_height programmatically for GridView for Android

Android set height and width of Custom view programmatically Ask Question. Asked 9 years, 1 month ago. Active 5 months ago. Viewed k times. Akram 7, 7 7 gold badges 42 42 silver badges 70 70 bronze badges. Active Oldest Votes. The easy way is to set the size programatically like that : graphView.

Dalmas Dalmas Would be helpful to know which LayoutParams you are importing there. The LayoutParams should be from the layout where the graphView is placed. You can set height and width like this: myGraphView.


comments

Leave a Reply