我正在使用这样的布局:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/logo"
android:orientation="horizontal" >
drawable/logo.xml
:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/login_logo"
android:gravity="center" />
drawable/login_logo.png
宽度为280像素,我的Galaxy Tab屏幕宽度为600px,但在推出的应用程序中,我看到图像几乎占据了所有屏幕宽度,大约是500像素
我在哪里弄错了?
解决
通过设置
<uses-sdk android:minSdkVersion="4" />
并将图片放到drawable-hdpi
答案 0 :(得分:2)
答案 1 :(得分:1)
我建议您好好阅读documentation。如果您已将图像放在drawable-mdpi文件夹中,则在高密度屏幕中,图像的大小将为1.5倍。您必须为不同的屏幕密度提供不同的图像分辨率。
答案 2 :(得分:1)
您在背景中设置图片,android:background
标记使用9张图片。因此,您的背景始终延伸到视图的宽度和高度。您的布局宽度设置为fill_parent
,因此图片宽度也为fill_parent
。
解决方案可能是使用.9.png
扩展名制作您正在使用的png的9补丁图像。
阅读here drawing 9 patch images - developer.android.com/guide/developing/tools/draw9patch.html