LAMW - How to set effect to imageview lazarus / 43-Android ---------------------------------------------------------------------- Agmcz · 2022-04-19 01:53 Hello all I want to get effect when click on imageview, like press a button!! ---------------------------------------------------------------------- jmpessoa · 2022-04-19 04:56 Hi, Agmcz! What about jImageBtn component ??? ---------------------------------------------------------------------- Agmcz · 2022-04-19 12:08 Quote from: jmpessoa on April 19, 2022, 06:56:22 am Hi, Agmcz! What about jImageBtn component ??? jImageBtn not enough image is large, so i want to use imageview and add ripple effect on click, just like button on click ---------------------------------------------------------------------- jmpessoa · 2022-04-21 19:36 Quotei want to use imageview and add ripple effect on click.... unfortunately all my attempts to implement ripple effect  for imageview  failed! I will keep trying.... Can you point out some good java/android example? ---------------------------------------------------------------------- Agmcz · 2022-04-22 00:27 Thank you, please don't fail  I will also try with you "jImageView.java" ---------------------------------------------------------------------- Agmcz · 2022-04-25 01:17 i found this code, but it is not required onTouchEvent DOWN: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i this.getDra wable().setColorFilter(0x77000000,PorterDuff.Mode.SRC_ATOP);this.inval idate();  UP: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i this.getDrawable().clearColorFilter();this.invalidate(); ---------------------------------------------------------------------- Agmcz · 2022-04-25 01:38 How can I modify the design of components via an xml file? ---------------------------------------------------------------------- jmpessoa · 2022-04-25 03:21 QuoteHow can I modify the design of components via an xml file? There is a  demo  "AppApplyDrawableXMLDemo1" ---------------------------------------------------------------------- Agmcz · 2022-04-25 18:49 Quote from: jmpessoa on April 25, 2022, 05:21:59 amThere is a  demo  "AppApplyDrawableXMLDemo1" Very cool, but I want to add this to "ImageView1"  Code: [Select] ---------------------------------------------------------------------- jmpessoa · 2022-04-25 19:04 Well, at the moment we can't.... We have no way to create a component by a xml code in LAMW.... (and this would be really important...) But, we can try configure and reconfigure some properties and even add some missing property... Here the relavant is: Quoteandroid:background="?android:attr/selectableItemBackground" But I still haven't learned how handle it programmatically.... ---------------------------------------------------------------------- Agmcz · 2022-04-26 03:40 Quote from: jmpessoa on April 25, 2022, 09:04:53 pmBut I still haven't learned how handle it programmatically.... pls note here https://gist.github.com/JakeWharton/0a251d67649305d84e8a ---------------------------------------------------------------------- Agmcz · 2022-05-19 13:14 I'm still trying but something is confusing...  this code is working successfully with Android Studio Code: [Select]TypedValue outValue = new TypedValue(); getBaseContext().getTheme().resolveAttribute(android.R.attr.selectable ItemBackground, outValue, true); ImageView myimage = (ImageView) findViewById(R.id.imageView); myimage.setForeground(getDrawable(outValue.resourceId)); myimage.setClickable(true); but with LAMW it is not working successfully  Code: [Select]TypedValue outValue = new TypedValue(); controls.activity.getTheme().resolveAttribute(R.attr.selectableItemBac kground, outValue, true); this.setForeground(controls.activity.getResources().getDrawable(outVal ue.resourceId)); this.setClickable(true); ---------------------------------------------------------------------- Agmcz · 2022-05-28 17:45 Ok finished! the problem was from event onTouchEvent ImageView.java 1- Disable event onTouchEvent Code: [Select]/* public  boolean onTouchEvent( MotionEvent event) { ... } */          2- Add onClickListener event in constructor Code: [Select]onClickListener = new OnClickListener() {   public  void onClick(View view) {     controls.pOnClick(PasObj,Const.Click_Default);   } }; setOnClickListener(onClickListener); 3- Add new proc Code: [Select]public void SetRippleEffect() {   TypedValue typedValue = new TypedValue();   controls.activity.getTheme().resolveAttribute(R.attr.selectableItemB ackground, typedValue, true);   int[] attrs = new int[]{R.attr.selectableItemBackground};   TypedArray typedArray = controls.activity.obtainStyledAttributes(typedValue.resourceId, attrs);   this.setForeground(typedArray.getDrawable(0));   this.setClickable(true);   typedArray.recycle(); } Laz_And_Controls.pas Code: [Select]procedure jImageView.SetRippleEffect; begin   if FInitialized then     jni_proc(gApp.jni.jEnv, FjObject, 'SetRippleEffect'); end; Using: Code: [Select]ImageView1.SetRippleEffect; ---------------------------------------------------------------------- jmpessoa · 2022-05-28 22:27 QuoteOk finished! Nice! Please, can you post here a simple [demo] project.... Thank you! ---------------------------------------------------------------------- Agmcz · 2022-05-29 00:16 Quote from: jmpessoa on May 29, 2022, 12:27:37 amPlease, can you post here a simple [demo] project.... Demo attached. ---------------------------------------------------------------------- jmpessoa · 2022-05-30 05:19 QuoteDemo attached. Done! Added to LAMW github: new demo  "AppImageViewRippleEffectDemo1" ! Note: updated/fixed "onTouchEvent"  in   "jImageView.java"   to  support ripple effect!!! Thank you!!!!