r21nomi / GLRippleView

Custom GLSurfaceView for Android to show image with ripple effect using OpenGL.
228 stars 34 forks source link

Effect not appear. #11

Closed pateljc closed 6 years ago

pateljc commented 6 years ago

i m not able to see any effects here is my code:- gl = (GLRippleView) findViewById(R.id.gl_view); gl.setRippleOffset(0.01f); gl.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE) { float x = event.getX(); float y = event.getY(); gl.setRipplePoint(new Pair(util.map(event.getX(), 0f, new Util_A(MainActivity.this).getDisplayWidth(), -1f, 1f), util.map(event.getY(), 0f, new Util_A(MainActivity.this).getDisplayHieght(), -1f, 1f))); float j = (util.map(event.getX() / new Util_A(MainActivity.this).getDisplayWidth(), 0f, 1f, 0f, 0.02f)); gl.setRippleOffset(j); } return false; } });

r21nomi commented 6 years ago

How about simple implementation like below? You can apply ripple effect to your image with this code.

layout.xml

<r21nomi.com.glrippleview.GLRippleView
        android:id="@+id/gl_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:backgroundImage="@drawable/bg" />

MainAtivity

gl.setRippleOffset(0.01f)

If this doesn't work fine, it might be a bug depend on your device.

pateljc commented 6 years ago

i tried my code in different device and it work fine. thank u for your valuable time and response.

r21nomi commented 6 years ago

I'm glad to hear that. I close this issue.