Android image size

时间:2016-08-31 12:18:42

标签: android

I have designed this screen:Sample Screen

I am testing it on redmi note3 phone. I have placed my images in mipmap-xxhdpi. All the icons are of size 144x144 . But these look very big. Should I move this to drawable folder. SHould I reduce the size of the images. I have read that icons should be of 144x144 for xxhdpi. How should I decide what should be the size of my image. How will it adjust to different screen densities? Here's my xml file:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/login_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:background="@android:color/black"
    tools:context=".ui.activity.LoginActivity"
    android:isScrollContainer="true">

    <ImageView
        android:layout_centerHorizontal="true"
        android:id="@+id/logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />

    <TextView
        android:layout_centerHorizontal="true"
        android:layout_below="@id/logo"
        android:id="@+id/welcome_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/welcome_text"/>

    <EditText
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_centerHorizontal="true"
        android:id="@+id/email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/welcome_text"
        android:hint="@string/user_name"
        android:inputType="textEmailAddress"
        android:paddingTop="@dimen/activity_horizontal_margin"
        android:paddingBottom="@dimen/activity_horizontal_margin"
        android:paddingStart="10dp"
        android:paddingLeft="10dp"
        android:drawableLeft="@mipmap/usr"
        android:drawablePadding="10dp"
        android:background="@drawable/edittext_border"/>

    <EditText
        android:paddingTop="@dimen/activity_horizontal_margin"
        android:paddingBottom="@dimen/activity_horizontal_margin"
        android:paddingStart="10dp"
        android:paddingLeft="10dp"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_centerHorizontal="true"
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/email"
        android:hint="@string/pass"
        android:inputType="textPassword"
        android:drawablePadding="20dp"
        android:drawableLeft="@mipmap/pass"
        android:background="@drawable/edittext_border" />


    <Button
        android:layout_centerHorizontal="true"
        android:textColor="@android:color/white"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:background="@color/signin_color_orange"
        android:id="@+id/signin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/password"
        android:text="Sign In" />

    <ImageView
        android:layout_below="@id/signin"
        android:id="@+id/oval_sep"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/oval"
        android:layout_centerHorizontal="true" />
    <View
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:id="@+id/left_sep"
        android:layout_below="@id/signin"
        android:layout_toLeftOf="@+id/oval_sep"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="@color/border_color"/>
    <View
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:id="@+id/right_sep"
        android:layout_below="@id/signin"
        android:layout_toRightOf="@+id/oval_sep"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/border_color" />
    <TextView
        android:id="@+id/or_text"
        android:elevation="8dp"
        android:layout_toRightOf="@id/left_sep"
        android:layout_below="@id/signin"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="OR"
        android:textColor="@color/black_overlay"/>
    <TextView
        android:layout_centerHorizontal="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/signup_txt"
        android:id="@+id/signup_txt"
        android:layout_below="@id/oval_sep" />
    <View
        android:id="@+id/social_sep"
        android:layout_below="@id/signup_txt"
        android:layout_width="1dp"
        android:layout_height="1dp"
        android:background="@color/signin_color_orange"
        android:layout_centerHorizontal="true"/>
    <ImageButton
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:src="@drawable/google"
        android:layout_below="@id/signup_txt"
        android:background="@drawable/social_button_border"
        android:id="@+id/google"
        android:layout_toLeftOf="@+id/social_sep"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <ImageButton
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_marginLeft="-2dp"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:src="@mipmap/fb"
        android:layout_below="@id/signup_txt"
        android:layout_toRightOf="@id/social_sep"
        android:background="@drawable/social_button_border_fb"
        android:id="@+id/fb"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <View

        android:id="@+id/btn_sep"
        android:layout_below="@id/fb"
        android:layout_width="1dp"
        android:layout_height="1dp"
        android:background="@android:color/transparent"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"/>
    <Button
        android:layout_toLeftOf="@id/btn_sep"
        android:id="@+id/lost_pswd"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/account_border"
        android:text="@string/lost_pswd"
        android:layout_alignParentBottom="true"/>
    <Button
        android:background="@drawable/account_border"
        android:text="@string/create_accnt"
        android:id="@+id/crt_accnt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/lost_pswd"/>
</RelativeLayout>

3 个答案:

答案 0 :(得分:0)

It depends on the resolution that you are designing your PSD. There is no standard size for each pixel density. For example any image in xhdpi must be half the size of xxxhdpi, but they will display with the same size on corresponding devices. If your PSD is for xhdpi, then put your cropped icons in your xhdpi folder.

答案 1 :(得分:0)

你必须创建四个维度文件并相应地为图像提供正确的高度和高度

示例:

android:width="@dimen/one"

答案 2 :(得分:0)

首先,您必须将要在应用中使用的所有图像放入可绘制的应用程序中。对于不同的分辨率,有不同的可绘制文件夹,如drawable-mdpi(中等分辨率-48x48),drawable-hdpi(高分辨率-72x72),drawable-xhdpi(超高分辨率-96x96),drawable-xxhdpi(额外的超高分辨率-144x144) ),drawable-xxxhdpi(额外的额外高分辨率 - 192x192)。

如果您将每个分辨率图像放入各自的文件夹,则应用程序大小可能会增加。因此,为了避免将高分辨率图像放在drawable-xxxhdpi中,它会自动调整到剩余分辨率。最佳做法是创建一个大小为192x192的图像并将其放在drawable-xxxhdpi文件夹中。