我试着去做它和它的工作..唯一的区别我使用了相对的layoyt..检查这个代码:
布局:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="2000px"
android:layout_height="1125px"
tools:context=".MainActivity" >
<VideoView
android:id="@+id/videoView"
android:layout_width="2000px"
android:layout_height="1125px"
android:layout_marginTop="0px"
android:layout_marginLeft="0px" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="right"
android:onClick="goright"
/>
<Button
android:layout_width="wrap_content"
android:layout_marginLeft="100px"
android:layout_height="wrap_content"
android:text="down"
android:onClick="godown"
/>
</RelativeLayout>
和代码是:
public class MainActivity extends Activity {
private VideoView vv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vv = (VideoView) findViewById(R.id.videoView);
vv.setVideoPath("sdcard/foo/foo.mp4");
vv.start();
}
public void goright(View v) {
RelativeLayout.LayoutParams ll = (RelativeLayout.LayoutParams) vv
.getLayoutParams();
ll.setMargins(ll.leftMargin - 100, ll.topMargin, ll.rightMargin,
ll.bottomMargin);
vv.setLayoutParams(ll);
}
public void godown(View v) {
RelativeLayout.LayoutParams ll = (RelativeLayout.LayoutParams) vv
.getLayoutParams();
ll.setMargins(ll.leftMargin, ll.topMargin - 100, ll.rightMargin,
ll.bottomMargin);
vv.setLayoutParams(ll);
}
}
有两个按钮可以将视频向右或向下移动 100px
祝你好运,