我的应用程序中心有一个圆形的圆圈。在480x800的分辨率下,一切都很完美,但在320x480的分辨率下,这个圆圈太小了。我在470px x 470px的drawable-hdpi文件夹中有一个circle.png。我试图在drawable-mdpi文件夹中添加一个310x310的circle.png,但结果相同。 这是布局的XML代码:密度独立
<ImageView
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
/>
是否有可能圆只有几个像素距离的左侧和显示器的右侧边缘的每一项决议?
http://imageshack.us/photo/my-images/857/apppv.jpg/
编辑:我到底这种方式解决了这个问题:
LayoutParams lp = indicator.getLayoutParams();
lp.width = (int) (disW-(disW*0.06));
lp.height = (int) (disW-(disW*0.06));
indicator.setLayoutParams(lp);
//这工作得很好,纵横比是正确的。
EDIT2:这不是一个解决办法可言,因为缩放图像的图像质量实在是太差了...但我发现了两个教程: http://developer.sonymobile.com/wp/2011/06/27/how-to-scale-images-for-your-android%E2%84%A2-application/ http://android.creid.eu/how-to调整大小-AN-图像和保存质量/
我得把这是最好的办法......
你应该用'[android-layout]'而不是'[layout]':)来标记这个标记 –