Roh*_*hit 1 android android-video-player android-mediaplayer android-view android-videoview
我在朗姆酒
时使用此代码更改视频因此,我正在使用此代码
VideoView video;
DisplayMetrics dm;
dm=new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm);
height=dm.heightPixels;
width=dm.widthPixels;
video.setMinimumHeight(height);
video.setMinimumWidth(width);
Run Code Online (Sandbox Code Playgroud)
点击菜单项我正在使用它
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case SMALL:
video.setMinimumHeight(height/2);
video.setMinimumWidth(width/2);
Toast.makeText(getApplicationContext(), "Small called", Toast.LENGTH_LONG).show();
break;
case DEFAULT:
video.setMinimumHeight(height);
video.setMinimumWidth(width);
Toast.makeText(getApplicationContext(), "Default called", Toast.LENGTH_LONG).show();
break;
}
return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)
但仍然没有改变......有人可以帮忙吗?
你需要使用video.layout(左,上,右,下); 为了你的目的.
你能尝试一下吗?
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case SMALL:
// YOU CAN CREATE LEFT, TOP, RIGHT, BOTTOM FOR YOUR VIEW AND SET.
int left = video.getLeft();
int top = video.getTop();
int right = left + (width / 2);
int botton = top + (height / 2);
video.layout(left, top, right, bottom);
Toast.makeText(getApplicationContext(), "Small called", Toast.LENGTH_LONG).show();
break;
case DEFAULT:
// YOU CAN CREATE LEFT, TOP, RIGHT, BOTTOM FOR YOUR VIEW AND SET.
int left = video.getLeft();
int top = video.getTop();
int right = left + (width);
int botton = top + (height);
video.layout(left, top, right, bottom);
Toast.makeText(getApplicationContext(), "Default called", Toast.LENGTH_LONG).show();
break;
}
return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)
我认为它应该有效.