How to center in the screen the app with is smaller than the screen?

I made this sample and setted my father layout to be like 320 x 480 dp and when i pt it on a 800x480 there's a black space down there... how can i like center it so it have a equal black space at top and at bottom?

Posts

  • VijayReddyVijayReddy INMember

    If you parent layout (800x480) is RelativeLayout use the below properties for your child layout

    android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true"

    If your parent layout is Linearlayout then use below properties for your parent layout
    android:gravity="center" android:orientation="vertical"

    Example :

    <LinearLayout android:id="@+id/testlinearlayout" android:layout_width="XXXdp" android:layout_height="XXXdp" android:gravity="center" android:orientation="vertical" >

Sign In or Register to comment.