I need to center a imageview on the screen, but programatically, without using XML layouts.
I am actually using a FrameLayout, but i dont know how to center it on the FrameLayout.
This is the code i have until now:
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);
I think this should do it: