private void setHeaderPadding(int padding) { headerPadding = padding; MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) header.getLayoutParams(); mlp.setMargins(0, Math.round(padding), 0, 0); header.setLayoutParams(mlp); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.public_video_xml); initView(); // 跳转到录制页面 Init_View(); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); surfaceView = (TextureView) findViewById(R.id.preview_video); RelativeLayout preview_video_parent = (RelativeLayout) findViewById(R.id.preview_video_parent); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) preview_video_parent.getLayoutParams(); layoutParams.width = displaymetrics.widthPixels; layoutParams.height = displaymetrics.widthPixels; preview_video_parent.setLayoutParams(layoutParams); surfaceView.setSurfaceTextureListener(this); surfaceView.setOnClickListener(this); path = getIntent().getStringExtra("path"); imagePlay = (ImageView) findViewById(R.id.previre_play); imagePlay.setOnClickListener(this); mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); }