Java Code Examples for android.view.TextureView#getLayoutParams()
The following examples show how to use
android.view.TextureView#getLayoutParams() .
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: FragmentShowImage.java From iGap-Android with GNU Affero General Public License v3.0 | 5 votes |
/** * 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 2
Source File: OverlayDisplayWindow.java From media-samples with Apache License 2.0 | 4 votes |
private void createWindow() { LayoutInflater inflater = LayoutInflater.from(mContext); mWindowContent = inflater.inflate( R.layout.overlay_display_window, null); mWindowContent.setOnTouchListener(mOnTouchListener); mTextureView = (TextureView)mWindowContent.findViewById( R.id.overlay_display_window_texture); mTextureView.setPivotX(0); mTextureView.setPivotY(0); mTextureView.getLayoutParams().width = mWidth; mTextureView.getLayoutParams().height = mHeight; mTextureView.setOpaque(false); mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); mNameTextView = (TextView)mWindowContent.findViewById( R.id.overlay_display_window_title); mNameTextView.setText(mName); mWindowParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mWindowParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; if (DISABLE_MOVE_AND_RESIZE) { mWindowParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; } mWindowParams.alpha = WINDOW_ALPHA; mWindowParams.gravity = Gravity.TOP | Gravity.LEFT; mWindowParams.setTitle(mName); mGestureDetector = new GestureDetector(mContext, mOnGestureListener); mScaleGestureDetector = new ScaleGestureDetector(mContext, mOnScaleGestureListener); // Set the initial position and scale. // The position and scale will be clamped when the display is first shown. mWindowX = (mGravity & Gravity.LEFT) == Gravity.LEFT ? 0 : mDefaultDisplayMetrics.widthPixels; mWindowY = (mGravity & Gravity.TOP) == Gravity.TOP ? 0 : mDefaultDisplayMetrics.heightPixels; Log.d(TAG, mDefaultDisplayMetrics.toString()); mWindowScale = INITIAL_SCALE; // calculate and save initial settings updateWindowParams(); saveWindowParams(); }
Example 3
Source File: OverlayDisplayWindow.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private void createWindow() { LayoutInflater inflater = LayoutInflater.from(mContext); mWindowContent = inflater.inflate( com.android.internal.R.layout.overlay_display_window, null); mWindowContent.setOnTouchListener(mOnTouchListener); mTextureView = (TextureView)mWindowContent.findViewById( com.android.internal.R.id.overlay_display_window_texture); mTextureView.setPivotX(0); mTextureView.setPivotY(0); mTextureView.getLayoutParams().width = mWidth; mTextureView.getLayoutParams().height = mHeight; mTextureView.setOpaque(false); mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); mTitleTextView = (TextView)mWindowContent.findViewById( com.android.internal.R.id.overlay_display_window_title); mTitleTextView.setText(mTitle); mWindowParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY); mWindowParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; if (mSecure) { mWindowParams.flags |= WindowManager.LayoutParams.FLAG_SECURE; } if (DISABLE_MOVE_AND_RESIZE) { mWindowParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; } mWindowParams.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; mWindowParams.alpha = WINDOW_ALPHA; mWindowParams.gravity = Gravity.TOP | Gravity.LEFT; mWindowParams.setTitle(mTitle); mGestureDetector = new GestureDetector(mContext, mOnGestureListener); mScaleGestureDetector = new ScaleGestureDetector(mContext, mOnScaleGestureListener); // Set the initial position and scale. // The position and scale will be clamped when the display is first shown. mWindowX = (mGravity & Gravity.LEFT) == Gravity.LEFT ? 0 : mDefaultDisplayInfo.logicalWidth; mWindowY = (mGravity & Gravity.TOP) == Gravity.TOP ? 0 : mDefaultDisplayInfo.logicalHeight; mWindowScale = INITIAL_SCALE; }
Example 4
Source File: OverlayDisplayWindow.java From android-MediaRouter with Apache License 2.0 | 4 votes |
private void createWindow() { LayoutInflater inflater = LayoutInflater.from(mContext); mWindowContent = inflater.inflate( R.layout.overlay_display_window, null); mWindowContent.setOnTouchListener(mOnTouchListener); mTextureView = (TextureView)mWindowContent.findViewById( R.id.overlay_display_window_texture); mTextureView.setPivotX(0); mTextureView.setPivotY(0); mTextureView.getLayoutParams().width = mWidth; mTextureView.getLayoutParams().height = mHeight; mTextureView.setOpaque(false); mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); mNameTextView = (TextView)mWindowContent.findViewById( R.id.overlay_display_window_title); mNameTextView.setText(mName); mWindowParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mWindowParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; if (DISABLE_MOVE_AND_RESIZE) { mWindowParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; } mWindowParams.alpha = WINDOW_ALPHA; mWindowParams.gravity = Gravity.TOP | Gravity.LEFT; mWindowParams.setTitle(mName); mGestureDetector = new GestureDetector(mContext, mOnGestureListener); mScaleGestureDetector = new ScaleGestureDetector(mContext, mOnScaleGestureListener); // Set the initial position and scale. // The position and scale will be clamped when the display is first shown. mWindowX = (mGravity & Gravity.LEFT) == Gravity.LEFT ? 0 : mDefaultDisplayMetrics.widthPixels; mWindowY = (mGravity & Gravity.TOP) == Gravity.TOP ? 0 : mDefaultDisplayMetrics.heightPixels; Log.d(TAG, mDefaultDisplayMetrics.toString()); mWindowScale = INITIAL_SCALE; // calculate and save initial settings updateWindowParams(); saveWindowParams(); }
Example 5
Source File: OverlayDisplayWindow.java From V.FlyoutTest with MIT License | 4 votes |
private void createWindow() { LayoutInflater inflater = LayoutInflater.from(mContext); mWindowContent = inflater.inflate( R.layout.overlay_display_window, null); mWindowContent.setOnTouchListener(mOnTouchListener); mTextureView = (TextureView)mWindowContent.findViewById( R.id.overlay_display_window_texture); mTextureView.setPivotX(0); mTextureView.setPivotY(0); mTextureView.getLayoutParams().width = mWidth; mTextureView.getLayoutParams().height = mHeight; mTextureView.setOpaque(false); mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); mNameTextView = (TextView)mWindowContent.findViewById( R.id.overlay_display_window_title); mNameTextView.setText(mName); mWindowParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mWindowParams.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; if (DISABLE_MOVE_AND_RESIZE) { mWindowParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; } mWindowParams.alpha = WINDOW_ALPHA; mWindowParams.gravity = Gravity.TOP | Gravity.LEFT; mWindowParams.setTitle(mName); mGestureDetector = new GestureDetector(mContext, mOnGestureListener); mScaleGestureDetector = new ScaleGestureDetector(mContext, mOnScaleGestureListener); // Set the initial position and scale. // The position and scale will be clamped when the display is first shown. mWindowX = (mGravity & Gravity.LEFT) == Gravity.LEFT ? 0 : mDefaultDisplayMetrics.widthPixels; mWindowY = (mGravity & Gravity.TOP) == Gravity.TOP ? 0 : mDefaultDisplayMetrics.heightPixels; Log.d(TAG, mDefaultDisplayMetrics.toString()); mWindowScale = INITIAL_SCALE; // calculate and save initial settings updateWindowParams(); saveWindowParams(); }