GLTextureView create hole behind it - android

Hello I worked on a GLTextureView to display an alpha video, but because of the alpha channel I setted
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
I tried a first time with a GLSurfaceView but the problem was that it needed a setZOrderOnTop(true)to show it and the view wasn't anymore attached to it's container (which is a zoomView).
A TextureViewis better but now I've my video in a hole rectangle on my container sadly!
Source:
wanted
--[EDIT]--
Here some exemple :
On top it's an GLSurfaceView with an alpha video and down a custom GLTextureView, both are in an horizontalView.
Top appears to be good as I want! But check this when I scroll to right:
Top still appear when bottom hide as it needed!

Related

Android YouTubePlayerView unauthorized overlay and too small error

I'm using Youtube Api for Android in my app, and i create new YouTubePlayerView dynamic in my activity such as:
YouTubePlayerView youTubePlayerView = new YouTubePlayerView(PlayerActivity.this);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(640, 360);
layoutParams.setMargins(100, 200, 0, 0);
youTubePlayerView.setLayoutParams(layoutParams);
root.addView(youTubePlayerView);
As the code, "root" is a RelativeLayout, and the size and margin of youTubePlayerView is different with each youTubePlayerView;
this code sometimes work, but sometimes not, it returns error below:
W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.google.android.youtube.player.YouTubePlayerView{37ab2582 V.E..... ......ID 0,0-0,0}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 0, top: 0, right: 0, bottom: 0 (these should all be positive).
or this one
W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to the player's view being too small. The YouTubePlayerView is 0dp wide (minimum is 200dp) and 0dp high (minimum is 110dp).
is there any way to avoid it happen, or let it play video successfully.
i appreciate any help.
Regards
Based on the Official Google Documentation, setting the flag leaves to you the task of handling the UI elements visibility.
YouTube player will detect that a view is being displayed over it and will throw that warning.
You can try with one of the following additional flags:
FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE:causes the player to automatically enter fullscreen whenever the device enters landscape orientation.
FULLSCREEN_FLAG_CONTROL_ORIENTATION: enables automatic control of the orientation.
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI: enables automatic control of system UI.
FULLSCREEN_FLAG_CUSTOM_LAYOUT:disables the default fullscreen layout handler, enabling you to control the transition to fullscreen layout manually.

Buttons text is not aligned any more after changing the BackgroundDrawable

i am changing my buttons' backgroundDrawable programaticaly:
myButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.card_button_blue));
After changing the background, the text in the button is not aligned any more like it was before changing the background.
(source: dsliga.eu)
target SDK version is 10.
Thanks.
Looks like the setText() method messes up the alignment. After changing the text, re-applying the gravity and padding did the job:
myButton.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
myButton.setPadding(12, 12, 12, 12);
Since you are using a 9patch, you need to specify with bottom and right side lines where the data is inside your drawing, you probably did not draw a full line at the bottom, and right side of the 9patch drawing
this is why the text inside your button stopped being centered, because the bounds of the 9patch are NOT what you think they are
your 9patch should (normally), leave only 1 pixel at the top and bottom of the right side line, and 1 pixel at the left and right of the bottom line
redraw the 9patch, remove the gravity and padding code, and see if it works
see below image

Android Game development - Imageview automatically shrinks at screen edge

I have a bunch of dynamically created ImageViews representing different objects in a game, which is working fine. However if any Image reaches the edge of the screen, it shrinks. Looks like android is attempting to create a smooth transition, but this is not wanted.
I found another thread with the same issue here: Animation Drawable gets automatically shrinks at the corners ?, however his solution does not work for me, it only enhances the issue as it starts shrinking once the margin hits the screen edge.
This is my code:
final LayoutParams _updated_params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
_updated_params.setMargins((int)m_x, (int)m_y, 0, 0);
m_image.setLayoutParams(_updated_params);</code>
Where m_x/m_y is the absolute position of the image and m_image is an ImageView instance.
Does anyone know how I can turn off this automatic resizing?
Add setScaleType
m_image.setScaleType(ScaleType.MATRIX);
Use setScaleType
m_image.setScaleType(ScaleType.FIT_XY);

Android padding problem

:) I'm having the following problem: I have a view and i want to add borders to it. What I'm currently trying to do is to set padding to the view (padding from all the sides) and set background color to it which will fill the padding. The thing is that it seems to me that it's possible to set padding either only from top and left or from bottom and right but not from all of them together. I.e if i write
view.setPadding(border,border,border,border)
this will set padding only from top and left. In order to set padding from bottom and right I have to write:
view.setPadding(-border,-border,0,0)
which won't leave left and top padding and so on. If I try to use margin it moves the whole block(the view + the padding area), but not only the view, so this doesn't seem to work either. Any ideas on how to do it without having to use a wrapping layout? Thanks!
What exactly happens when you use the first example?
The four int parameters for setPadding() are for left, top, right, and bottom, respectively. So, calling setPadding(4, 5, 6, 7) should give you 4 pixels of space for the left edge, 5 for the top, 6 for the right, and 7 for the bottom. What result are you getting when you do this? Can you show a screenshot?
What is the content of your view? If it's an image or something similar, perhaps it's not being centered or scaled properly. Try calling setGravity(CENTER);.

Android GLSurfaceView with drawable background

I have a GLSurfaceView with a drawable as background, however only the background is visible when rendered without surfaceView.setZOrderOnTop(true)
I need to avoid using setZOrderOnTop(true) because there are static TextView's being used on top of the GLSurfaceView.
Any suggestions for getting this to work?
GLSurfaceView cannot really have a background. The way a surface view works is by cutting a hole through your Activity's window and showing another surface behind. Setting setZOrderOnTop(true) moves the surface above the Activity's window.
false! You can do it.
Just an example to show how it works.
glRenderer = new OpenGLRenderer(context);
view = new GLSurfaceView(context);
view.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
view.setRenderer(glRenderer);
view.getHolder().setFormat(PixelFormat.RGBA_8888);
view.getHolder().setFormat(PixelFormat.TRANSLUCENT);
view.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
Then use framelayout to put a view under glsurfaceview!
Try setZOrderMediaOverlay(true); which should put the gl layer above the background but below the window.
Well, since GLSurfaceView is just another view, why not use a FrameLayout to place the GLSurfaceView on top of the ImageView (or whatever you're using to display the drawable.)

Categories

Resources