适用于所有屏幕尺寸和分辨率的Android设计

时间:2016-03-11 21:03:47

标签: android android-layout android-linearlayout android-drawable android-relativelayout

您好我正在开发一款具有此design的应用。通过大量的努力,我开发了this。但这仍然与给定的设计不同,在其他屏幕上我得到this。这是xml文件中的代码。任何帮助将不胜感激。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@mipmap/dashboard_bg"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@null"
            android:src="@mipmap/logo" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@null"
            android:src="@mipmap/logo" />
    </LinearLayout>

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="Welcome text of app" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="bottom" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:contentDescription="@null"
            android:src="@mipmap/seperator" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_above="@+id/imageView1"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:contentDescription="@null"
            android:src="@mipmap/regional_managers" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/imageView3"
            android:layout_toEndOf="@+id/imageView1"
            android:layout_toRightOf="@+id/imageView1"
            android:contentDescription="@null"
            android:src="@mipmap/regions" />

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignRight="@+id/imageView3"
           android:layout_alignEnd="@+id/imageView3"
            android:layout_below="@+id/imageView4"
            android:contentDescription="@null"
            android:src="@mipmap/graphs" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_alignTop="@+id/imageView1"
            android:layout_toLeftOf="@+id/imageView1"
            android:layout_toStartOf="@+id/imageView1"
            android:contentDescription="@null"
            android:src="@mipmap/nationwide" />

    </RelativeLayout>

</LinearLayout>

也尝试过这样的链接 image size (drawable-hdpi/ldpi/mdpi/xhdpi)Setting drawable folder to use for different resolutions但无法获得理想的结果。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        app:layout_marginTopPercent="10%"
        app:layout_widthPercent="30%" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_marginLeftPercent="20%"
        app:layout_marginTopPercent="40%"
        app:layout_widthPercent="20%" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_marginLeftPercent="60%"
        app:layout_marginTopPercent="55%"
        app:layout_widthPercent="20%" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_marginLeftPercent="30%"
        app:layout_marginTopPercent="70%"
        app:layout_widthPercent="20%" />

</android.support.percent.PercentRelativeLayout>
相关问题