public class ResizableVIDeoVIEw extends VIDeoVIEw { public ResizableVIDeoVIEw(Context c) { super(c); } private int mVIDeoWIDth = 100; private int mVIDeoHeight = 100; public voID changeVIDeoSize(int wIDth,int height) { mVIDeoWIDth = wIDth; mVIDeoHeight = height; // not sure whether it is useful or not but safe to do so getHolder().setFixedSize(wIDth,height); forceLayout(); invalIDate(); // very important,so that onMeasure will be triggered } public voID onMeasure(int specwIDth,int specheight) { Log.i("onMeasure","On Measure has been called"); setMeasuredDimension(mVIDeoWIDth,mVIDeoHeight); } public voID onDraw(Canvas c) { super.onDraw(c); Log.i("onDraw","Drawing..."); }}
视频在AndroID模拟器和Motorola DroID X上正确调整大小;但在摩托罗拉DroID上,VIDeoVIEw会调整大小,但VIDeoVIEw中播放的视频不会调整大小.在摩托罗拉DroID上,如果VIDeoVIEw设置为比视频播放更大的尺寸,VIDeoVIEw中会出现黑色背景,视频在VIDeoVIEw的左上角播放在黑色背景的顶部.
如何在AndroID中正确调整VIDeoVIEw的大小?
谢谢,
万斯
relativeLayout.LayoutParams vIDeovIEwlp = new relativeLayout.LayoutParams(newwIDth,newheight); vIDeovIEwlp.addRule(relativeLayout.CENTER_HORIZONTAL,relativeLayout.TRUE); vIDeovIEwlp.addRule(relativeLayout.CENTER_VERTICAL,relativeLayout.TRUE); vIDeovIEw.setLayoutParams(vIDeovIEwlp); vIDeovIEw.invalIDate();
通过使视频视图无效,您将强制它使用新的LayoutParams(以及新尺寸)重绘整个视频视图.
总结以上是内存溢出为你收集整理的android – 调整视频大小全部内容,希望文章能够帮你解决android – 调整视频大小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)