4 imageViews像2号线的中心* 2行对所有设备 [英] 4 imageViews in the center like 2 lines * 2 rows for all devices

查看:150
本文介绍了4 imageViews像2号线的中心* 2行对所有设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把4 imageViews就像他们在2行×2行:

i'm trying to put 4 imageViews like they was in 2 lines * 2 rows:

我这样做:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/accueil">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/font"
        android:src="@drawable/fond_menu"
        android:scaleType="centerCrop"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingBottom="20dp">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/topLogo"
                android:layout_marginTop="5dp"
                android:src="@drawable/logo_bleu_petit"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/topText"
                android:lineSpacingMultiplier="1.3"
                android:textSize="16sp"
                android:layout_below="@+id/topLogo"
                android:layout_centerHorizontal="true"
                android:width="260dp"
                android:layout_marginTop="15dp"
                android:gravity="center"
                android:textIsSelectable="false"
                android:layout_marginBottom="10dp" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/firstBlock"
                android:src="@drawable/encart_offres"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/topText"
                android:layout_alignParentRight="true"
                android:layout_marginRight="150dp" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/secondBlock"
                android:src="@drawable/encart_contact"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_below="@+id/topText"
                android:layout_alignParentBottom="false"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="false"
                android:layout_marginLeft="150dp" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/thirdBlock"
                android:src="@drawable/encart_actualites"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/firstBlock"
                android:layout_marginTop="40dp"
                android:layout_marginLeft="150dp"
                android:layout_alignParentRight="true" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/fourthBlock"
                android:src="@drawable/encart_mentions"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:layout_below="@+id/secondBlock"
                android:layout_marginTop="40dp"
                android:layout_marginRight="150dp"
                android:layout_alignParentLeft="true" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="80dp"
                android:id="@+id/formulaire"
                android:layout_marginTop="15dp"
                android:layout_below="@+id/fourthBlock"
                android:background="@drawable/bouton_formulaire"
                android:layout_centerHorizontal="true" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/bottomText"
                android:lineSpacingMultiplier="1.2"
                android:gravity="center"
                android:textColor="#626262"
                android:textSize="14sp"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="15dp"
                android:width="270dp"
                android:layout_below="@+id/formulaire" />

        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

不过,与不同设备的imageViews被它们或者是重叠的坚持。我觉得我必须使用行和列,但我不知道该怎么迪吧。

But with different Device the imageViews are stick between them or are overlap. I think i have to use lines and rows, but i don't know how to di it.

推荐答案

你为什么不使用TableLayout这样吗?

Why don't you use TableLayout like this?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/scroll">
        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <TableRow>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/topLogo1"
                    android:layout_marginTop="5dp"
                    android:src="@drawable/logo_bleu_petit"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true" />
            <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/topLogo2"
                    android:layout_marginTop="5dp"
                    android:src="@drawable/logo_bleu_petit"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true" />
            </TableRow>
            <TableRow>

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/topLogo3"
                    android:layout_marginTop="5dp"
                    android:src="@drawable/logo_bleu_petit"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true" />
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/topLogo4"
                    android:layout_marginTop="5dp"
                    android:src="@drawable/logo_bleu_petit"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true" />
            </TableRow>
        </TableLayout>
</ScrollView>

我希望这能适合你的问题。

I hope this can fit your question.

这篇关于4 imageViews像2号线的中心* 2行对所有设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆