Wie center-eine Bildansicht auf dem Bildschirm mit einem FrameLayout? (mit java-code)

Ich muss Mitte eine Bildansicht auf dem Bildschirm, sondern über ein Programm, ohne Verwendung von XML-layouts.

Ich bin eigentlich mit einem FrameLayout, aber ich weiß nicht, wie Sie es mittig auf das FrameLayout.

Dies ist der code, den ich habe bis jetzt:

        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);
Schreibe einen Kommentar