简体   繁体   中英

Android Layout with Images and Compatibility

I develop a photo album app. I would like to place photos on screen like the following layout :

布局

For this purpose, I decided to place a vertical linear layout at outside of all. Then place RelativeLayouts for each row. In each RelativeLayouts in a row, I put two relative layouts to contain the ImageViews. In each RelativeLayout I size them with proper "dp" as I draw at the image above.

My question is, can it be the same view in different phones with different resolutions ? If so, what would be the proper approach to have the view that I show above ?

Thanks

Use linear layout completely and make sure you know what layout_weight does. refer the following

http://developer.android.com/guide/topics/ui/declaring-layout.html#CommonLayouts

http://developer.android.com/guide/topics/ui/layout/linear.html#Weight

Try this...its only for 1 row, but you get the idea..this is inside vertical linear layout..

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:src="@drawable/ic_launcher"
        android:layout_height="wrap_content" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:orientation="vertical"
         >

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="1dp"
            android:src="@drawable/ic_launcher"
            android:layout_weight="1" 
            android:layout_gravity="center_horizontal"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:src="@drawable/ic_launcher"
                android:layout_height="wrap_content" />

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:src="@drawable/ic_launcher"
                android:layout_height="wrap_content" />

        </LinearLayout>
    </LinearLayout>
</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM