我正在实施此Layout
:
它包含手机内的Background Image
,Phone Image
和白色white view
。那个是gif animation
。
这是我的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:background="@drawable/empty_background"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/iphone_background">
<pl.droidsonroids.gif.GifImageView
android:id="@+id/inner_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="140dp"
android:layout_marginTop="240dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
我Nexus 5
Lollipop 5.0
看起来很好,但每个分辨率的Inner View
(gif)看起来都不一样。
任何帮助都会很棒,谢谢:)
答案 0 :(得分:0)
嗯这需要比特计算,你可以使用pixplicity.com并为不同尺寸的屏幕计算不同的dp尺寸。
例如:
如果xhdpi的原始图像尺寸为640 * 480像素,那么对于其他图像尺寸为
长度:
ldpi @ 320.00dp = 240.00px = 320.00sp = 50.80mm = 2.00in = 144.00pt
mdpi @ 320.00dp = 320.00px = 320.00sp = 50.80mm = 2.00in = 144.00pt
tvdpi @ 320.00dp = 426.00px = 320.00sp = 50.80mm = 2.00in = 144.00pt
hdpi @ 320.00dp = 480.00px = 320.00sp = 50.80mm = 2.00in = 144.00pt
xhdpi @ 320.00dp = 640.00px = 320.00sp = 50.80mm = 2.00in = 144.00pt
xxhdpi @ 320.00dp = 960.00px = 320.00sp = 50.80mm = 2.00in = 144.00pt
xxxhdpi @ 320.00dp = 1280.00px = 320.00sp = 50.80mm = 2.00in = 144.00pt
和广度:
ldpi @ 240.00dp = 180.00px = 240.00sp = 38.10mm = 1.50in = 108.00pt
mdpi @ 240.00dp = 240.00px = 240.00sp = 38.10mm = 1.50in = 108.00pt
tvdpi @ 240.00dp = 319.50px = 240.00sp = 38.10mm = 1.50in = 108.00pt
hdpi @ 240.00dp = 360.00px = 240.00sp = 38.10mm = 1.50in = 108.00pt
xhdpi @ 240.00dp = 480.00px = 240.00sp = 38.10mm = 1.50in = 108.00pt
xxhdpi @ 240.00dp = 720.00px = 240.00sp = 38.10mm = 1.50in = 108.00pt
xxxhdpi @ 240.00dp = 960.00px = 240.00sp = 38.10mm = 1.50in = 108.00pt
并且你需要为所有不同的图像保存相同的gif名称,并将它们相应地放在相应的可绘制文件夹中(mdpi,hdpi,xhdpi,xxhdpi)。
答案 1 :(得分:0)
Background Image
可以采用match_parent
尺寸。但是,对于Phone Image
和GIF Image
,请尝试将每个尺寸分开放在一个LinearLayouts
上 - 另外,并将layout_width
设置为0dp
和layout_height
至wrap_content
,同时指定layout_weight
以正确对齐视图,这可以使您的所有屏幕上的视图看起来都很相似。