Java Code Examples for android.view.TextureView#setLayoutParams()

The following examples show how to use android.view.TextureView#setLayoutParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FimiH264Video.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void init() {
    this.mVideoWidth = 0;
    this.mVideoHeight = 0;
    setBackgroundColor(ViewCompat.MEASURED_STATE_MASK);
    setFocusable(true);
    setFocusableInTouchMode(true);
    requestFocus();
    this.mCurrentState = 0;
    this.mTargetState = 0;
    TextureView renderUIView = new TextureView(getContext());
    renderUIView.setLayoutParams(new LayoutParams(-2, -2, 17));
    renderUIView.setSurfaceTextureListener(this.mSurfaceCallback);
    this.mX8Camera9GridView = new X8Camera9GridView(getContext());
    this.mX8Camera9GridView.setLayoutParams(new LayoutParams(-1, -1, 17));
    this.mX8AiTrackContainterView = new X8AiTrackContainterView(getContext());
    this.mX8AiTrackContainterView.setLayoutParams(new LayoutParams(-1, -1, 17));
    this.blackView = new View(getContext());
    this.blackView.setLayoutParams(new LayoutParams(-1, -1, 17));
    this.blackView.setBackgroundColor(getContext().getResources().getColor(R.color.black));
    addView(renderUIView);
    addView(this.mX8AiTrackContainterView);
    addView(this.blackView);
    addView(this.mX8Camera9GridView);
    showGridLine(GlobalConfig.getInstance().getGridLine());
}
 
Example 2
Source File: FragmentShowImage.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * get real width and height video
 */
private void getRealSize(MediaPlayer mp, TextureView mTextureView) {

    if (mp == null || mTextureView == null) {
        return;
    }

    //Get the dimensions of the video
    int videoWidth = mp.getVideoWidth();
    int videoHeight = mp.getVideoHeight();

    Display display = G.fragmentActivity.getWindowManager().getDefaultDisplay();

    int finalWith, finalHeight;

    finalWith = display.getWidth();
    finalHeight = (int) (((float) videoHeight / (float) videoWidth) * (float) display.getWidth());

    if (finalHeight > display.getHeight()) {
        finalWith = (int) (((float) finalWith / (float) finalHeight) * (float) display.getHeight());
        finalHeight = display.getHeight();
    }

    ViewGroup.LayoutParams lp = mTextureView.getLayoutParams();
    lp.width = finalWith;
    lp.height = finalHeight;
    mTextureView.setLayoutParams(lp);
}
 
Example 3
Source File: StandardVideoView.java    From TigerVideo with Apache License 2.0 5 votes vote down vote up
public TextureView createTextureView() {

        //重新为播放器关联TextureView
        TextureView textureView = newTextureView();
        FrameLayout.LayoutParams params =
                new FrameLayout.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        ViewGroup.LayoutParams.MATCH_PARENT,
                        Gravity.CENTER);
        textureView.setLayoutParams(params);
        return textureView;
    }
 
Example 4
Source File: DirectChain.java    From CameraCompat with MIT License 5 votes vote down vote up
@Override
public View createSurface(Context context) {
    mTextureView = new TextureView(context);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mTextureView.setLayoutParams(params);
    mTextureView.setKeepScreenOn(true);
    return mTextureView;
}
 
Example 5
Source File: VideoOverlay.java    From backgroundvideo with GNU General Public License v3.0 5 votes vote down vote up
public VideoOverlay(Context context) {
    super(context);

    this.setClickable(false);
    this.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    // Create surface to display the camera preview
    mPreview = new TextureView(context);
    mPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mPreview.setClickable(false);
    mPreview.setSurfaceTextureListener(this);
    attachView();
}