簡體   English   中英

如何為Android應用正確縮放圖像?

[英]How to scale image correctly for Android app?

我不明白如何在android中正確縮放圖像。 我有一個640 * 125像素的iPhone應用程序圖片。 我需要在Android應用中使用它,但我不知道如何正確縮放它。

在下面的圖像中,我將“ FitEnd”用作ScaleType,除了高度大約是其應有大小的兩倍外,它看起來還不錯(它應該與灰色圖形的最高部分一樣高)。

我該如何解決?

選擇顯示我需要縮放的圖像

編輯:包括.xml

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

        <ViewFlipper
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/buttonrow" >

            <ViewFlipper
                android:id="@+id/flipper"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <include
                    android:id="@+id/first"
                    layout="@layout/activity_events" />
                <include
                    android:id="@+id/second"
                    layout="@layout/event_detail" />
            </ViewFlipper>  
            <include
                android:id="@+id/second"
                layout="@layout/event_detail" />
        </ViewFlipper>

        <RelativeLayout
            android:id="@+id/buttonrow"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:scaleType="fitEnd"
                android:src="@drawable/bottombar" />


        </RelativeLayout>

    </RelativeLayout>

我有兩個版本:

  1. 圖像具有非透明背景。 所以圖像參數很好,問題出在你的照片上

  2. 如果不是第一個版本,請告訴我您的.xml文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM