【发布时间】:2012-08-07 15:36:36
【问题描述】:
在我的应用程序中,我使用的是图像。我不希望图像的宽度超过任何密度的任何屏幕尺寸的屏幕宽度。如何实现这一点以及我对所有 android 密度只使用一张图像而不是不同分辨率的图像时会出现什么问题?
【问题讨论】:
标签: android image width screen
在我的应用程序中,我使用的是图像。我不希望图像的宽度超过任何密度的任何屏幕尺寸的屏幕宽度。如何实现这一点以及我对所有 android 密度只使用一张图像而不是不同分辨率的图像时会出现什么问题?
【问题讨论】:
标签: android image width screen
试试这个,但您需要为每个分辨率调整大小的图像
hdpi、ldpi、mdpi 和 xdpi 分辨率
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/title_bar"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/desc"
android:src="@drawable/YourPicSource" />
</RelativeLayout>
【讨论】: