0

imageView を含む xml があります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/blockingLayer"
    android:layout_width="880px"
    android:layout_height="600px">
        <ImageView 
            android:layout_width="110px"
            android:layout_height="60px"
            android:id="@+id/fish_image_view"
            android:visibility="visible"
            android:layout_marginLeft="0px"
            android:layout_marginTop="350px"
            />
</RelativeLayout> 

コードでは、この imageView を取得し、 X1 = 10 から x2 = ScreenWidth 、 Y1 & Y2 = 350px まで translateAnimation を実行しています。このアニメーションは Android バージョン 2.2 では問題なく動作しますが、OS 2.3 / 4.0 でこれを実行すると、アニメーションの変換中に画面上のいくつかのポイントで ImageView が途切れて消えます。

これで何が問題なのか理解できませんでした。返信をお待ちしております。

4

1 に答える 1

3

「px」は使用しないでください。「ディップ」に変更

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/blockingLayer"
    android:layout_width="880dip"
    android:layout_height="600dip">
        <ImageView 
            android:layout_width="110dip"
            android:layout_height="60dip"
            android:id="@+id/fish_image_view"
            android:visibility="visible"
            android:layout_marginLeft="0dip"
            android:layout_marginTop="350dip"
            />
</RelativeLayout> 

ここからソース、Androidの「px」、「dp」、「dip」、「sp」の違いは何ですか?

px ピクセル - 画面上の実際のピクセルに対応します。

dp 密度に依存しないピクセル - 画面の物理密度に基づく抽象的な単位。これらの単位は 160 dpi スクリーンを基準にしたものであるため、1 dp は 160 dpi スクリーン上の 1 ピクセルです。dp とピクセルの比率は画面密度によって変化しますが、必ずしも正比例するとは限りません。注: コンパイラは "dip" と "dp" の両方を受け入れますが、"dp" は "sp" とより一貫性があります。

于 2012-07-13T07:39:25.967 に答える