Everything is gonna be alright.



import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView imageView = findViewById(R.id.imageView); RelativeLayout parentLayout = findViewById(R.id.parentLayout); // Add an invisible view on top of the image View overlayView = new View(this); overlayView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); parentLayout.addView(overlayView, params); // Set a click listener on the overlay to capture screenshot attempts overlayView.setOnClickListener(view -> { // Handle screenshot attempt (e.g., show a warning) // You can also disable the click action to prevent interaction }); // Set your image resource imageView.setImageResource(https://static6.depositphotos.com/1000423/604/i/450/depositphotos_6044122-stock-photo-highway-road-going-up.jpg); } }
أحدث أقدم