2016-08-31 128 views
0

我設計了此屏幕:Sample ScreenAndroid圖片大小

我正在redmi note3手機上測試它。我已將我的圖像放在mipmap-xxhdpi中。所有圖標的大小爲144x144。但是這些看起來很大。我應該將其移至可繪製文件夾。我應該減少圖像的大小。我已經讀過xxhdpi的圖標應該是144x144。我應該如何決定我的圖像的大小。它將如何適應不同的屏幕密度? 這裏是我的xml文件:

<?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> 
+1

'我把我的圖片放在mipmap-xxhdpi. ** **錯誤**:您必須使用'drawable-xxhdpi'。由於mipmap僅適用於啓動器圖標**。您可能想閱讀[官方文檔](https://developer.android.com/guide/practices/ui_guidelines/icon_design.html) –

回答

0

這取決於您設計PSD的分辨率。每個像素密度沒有標準尺寸。例如,xhdpi中的任何圖像必須是xxxhdpi大小的一半,但它們將在相應的設備上以相同的大小顯示。如果你的PSD是用於xhdpi的,那麼把你的裁剪圖標放在你的xhdpi文件夾中。

0

您必須建立四個維度的文件,並給圖像正確withs和相應的高度

例如:

android:width="@dimen/one" 
+0

...四?那麼ldpi呢?還是xxxhdpi?我會說你需要**六個**文件。 –

0

首先,你必須把所有的,你會在使用的圖片應用程序把他們放在可繪製的應用程對於不同的分辨率,有drawable-mdpi(中等分辨率-48x48),drawable-hdpi(高分辨率-72x72),drawable-xhdpi(超高分辨率-96x96),drawable-xxhdpi(超高分辨率 - 144x144) ),drawable-xxxhdpi(額外的超高分辨率 - 192x192)。

如果將每個分辨率圖像放入其各自的文件夾中,應用程序大小可能會增加。所以爲了避免把高分辨率的圖像放在drawable-xxxhdpi裏面,它會自動調整到剩下的分辨率。最佳做法是創建一個尺寸爲192x192的圖像,並將其放在drawable-xxxhdpi文件夾中。