I need to center the image on the screen, but programmatically, without using XML layouts.
I actually use FrameLayout, but I donβt know how to focus it on FrameLayout.
This is the code that I still have:
FrameLayout fl = new FrameLayout(this.getApplicationContext()); splash = new ImageView(getApplicationContext()); splash.setImageResource(R.drawable.logo); splash.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); fl.addView(splash); fl.setBackgroundColor(Color.BLACK); setContentView(fl);
source share