Android(新手)图像/布局/缩放问题
我是一个彻头彻尾的傻瓜,所以我可能把基本知识搞错了,但这让我很困惑 我这里有一个图像按钮和一个背景图像 (注:比基尼女孩可能是NSFW——我想如果我要长时间看到这个屏幕,我可能会在那里看到一些有趣的东西;D) 正如您可以看到的,在不同的屏幕尺寸下,背景图像的缩放效果很好,但“我的图像”按钮起初有一个奇怪的边框,然后它开始缩小 我在36x36、48x48、72x72和96x96中制作了相同的图像按钮,并将它们放在 可绘制ldpi、可绘制mdpi、可绘制hdpi目录,无任何更改:( 如何使所有屏幕上的按钮都相同? 我是在DIP上读的,但我该在哪里声明呢 谢谢 编辑XML代码:Android(新手)图像/布局/缩放问题,android,android-layout,Android,Android Layout,我是一个彻头彻尾的傻瓜,所以我可能把基本知识搞错了,但这让我很困惑 我这里有一个图像按钮和一个背景图像 (注:比基尼女孩可能是NSFW——我想如果我要长时间看到这个屏幕,我可能会在那里看到一些有趣的东西;D) 正如您可以看到的,在不同的屏幕尺寸下,背景图像的缩放效果很好,但“我的图像”按钮起初有一个奇怪的边框,然后它开始缩小 我在36x36、48x48、72x72和96x96中制作了相同的图像按钮,并将它们放在 可绘制ldpi、可绘制mdpi、可绘制hdpi目录,无任何更改:( 如何使所有屏幕
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/background_ass">
<TableLayout android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:layout_width="fill_parent">
<TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/level1"
android:id="@+id/imageButton1"
android:onClick="button_clicked1"
android:background="#00000000" android:layout_width="48dip" android:layout_height="48dip">
</ImageButton>
</TableRow>
<TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</TableRow>
<TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content">
</TableRow>
<TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>
</TableLayout>
</LinearLayout>
Afaik图像按钮有一个最小尺寸,即可见边框。您可以通过定义透明背景和零填充来消除它:
<ImageButton ... background="#00000000" padding="0px"/>
拥有代码后更新:这里的问题是ImageButton的宽度和高度是固定的,并且没有告诉图像缩放。
给出一些关于处理多个屏幕大小/分辨率的说明,但这不是一个小问题!
我的建议是,根据您的需要:
- 如果所有设备上的相对大小(dip)应完全相同,请在ImageButton的声明中添加scaleType=“fitXY”
- 如果可以稍微更改大小,请将布局宽度和布局高度设置为“包裹内容”