私はそれをやろうとしましたが、その作業..相対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 右または下に移動するための 2 つのボタンがあります。
幸運を、