描画可能なのintrinsicWidth、intrinsicHeight解像度

参考:研究の画像サイズと解像度

本来の英国[ɪntrɪnzɪk]
米国[ɪntrɪnzɪk]
固有ADJ;固有の、自身

SO-固有

Drawableの

intrinsicWidth、intrinsicHeightプロパティが引き出し可能です

public abstract class Drawable {

    /**
     * Returns the drawable's intrinsic width.
     * <p>
     * Intrinsic width is the width at which the drawable would like to be laid
     * out, including any inherent padding. If the drawable has no intrinsic
     * width, such as a solid color, this method returns -1.
     *
     * @return the intrinsic width, or -1 if no intrinsic width
     */
    public int getIntrinsicWidth() {
        return -1;
    }

    /**
     * Returns the drawable's intrinsic height.
     * <p>
     * Intrinsic height is the height at which the drawable would like to be
     * laid out, including any inherent padding. If the drawable has no
     * intrinsic height, such as a solid color, this method returns -1.
     *
     * @return the intrinsic height, or -1 if no intrinsic height
     */
    public int getIntrinsicHeight() {
        return -1;
    }
}

テスト


    <ImageView
        android:id="@+id/iv"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@color/colorAccent"
        android:contentDescription="简单的图片"
        android:src="@mipmap/guide" />

    <ImageView
        android:id="@+id/iv2"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@color/colorAccent"
        android:contentDescription="加了padding"
        android:padding="10dp"
        android:src="@mipmap/guide" />

    <ImageView
        android:id="@+id/iv3"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@color/colorAccent"
        android:contentDescription="scaleType : fitXY"
        android:scaleType="fitXY"
        android:src="@mipmap/guide" />

    <ImageView
        android:id="@+id/iv4"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_margin="10dp"
        android:background="@color/colorAccent"
        android:contentDescription="加了margin"
        android:src="@mipmap/guide" />
  • ic_launcher.png
xxxhdpi xxhdpi xhdpi hdpi MDPI
幅/高さ(ピクセル) 192 144 96 72 48
割合 4 3 2 1.5 1
  • 携帯電話の画面をテスト

密度:320dp / xhdpi / 2.0倍

画面の解像度:720×1440px

  • テスト画像

幅640ピクセル* 1136px長身

幅/高さ/はmeasuredWidth / measuredHeightの取得のすべては、200(PX = 100dp * 2)、携帯電話の解像度に関連する唯一の高と広いレイアウト図です。

intrinsicWidth、intrinsicHeight:元の画像の幅と高さ、フォルダや携帯電話関連を配置する画像の解像度。

xxxhdpi xxhdpi xhdpi hdpi MDPI
割合 0.5 0.67 1 1.3 2

ミップマップ・xxxhdpiに幅640ピクセル* 1136px背の高い絵

==================第一个  intrinsicWidth: 320
==================第一个  intrinsicHeight: 568
==================第2个  intrinsicWidth: 320
==================第2个  intrinsicHeight: 568
==================第③个  intrinsicWidth: 320
==================第③个  intrinsicHeight: 568
==================第肆个  intrinsicWidth: 320
==================第肆个  intrinsicHeight: 568

ミップマップ・xxhdpiに幅640ピクセル* 1136px背の高い絵

==================第一个  intrinsicWidth: 427
==================第一个  intrinsicHeight: 757
==================第2个  intrinsicWidth: 427
==================第2个  intrinsicHeight: 757
==================第③个  intrinsicWidth: 427
==================第③个  intrinsicHeight: 757
==================第肆个  intrinsicWidth: 427
==================第肆个  intrinsicHeight: 757

ミップマップ-xhdpiに幅640ピクセル* 1136px背の高い絵

==================第一个  intrinsicWidth: 640
==================第一个  intrinsicHeight: 1136
==================第2个  intrinsicWidth: 640
==================第2个  intrinsicHeight: 1136
==================第③个  intrinsicWidth: 640
==================第③个  intrinsicHeight: 1136
==================第肆个  intrinsicWidth: 640
==================第肆个  intrinsicHeight: 1136

ミップマップ-hdpiに幅640ピクセル* 1136px背の高い絵


==================第一个  intrinsicWidth: 853
==================第一个  intrinsicHeight: 1515
==================第2个  intrinsicWidth: 853
==================第2个  intrinsicHeight: 1515
==================第③个  intrinsicWidth: 853
==================第③个  intrinsicHeight: 1515
==================第肆个  intrinsicWidth: 853
==================第肆个  intrinsicHeight: 1515

ミップマップ - MDPIの幅640ピクセル* 1136px背の高い絵

==================第一个  intrinsicWidth: 1280
==================第一个  intrinsicHeight: 2272
==================第2个  intrinsicWidth: 1280
==================第2个  intrinsicHeight: 2272
==================第③个  intrinsicWidth: 1280
==================第③个  intrinsicHeight: 2272
==================第肆个  intrinsicWidth: 1280
==================第肆个  intrinsicHeight: 2272

公開された767元の記事 ウォンの賞賛204 ビュー920 000 +

おすすめ

転載: blog.csdn.net/sinat_31057219/article/details/104798364
おすすめ