【发布时间】:2016-07-27 00:03:59
【问题描述】:
我的应用程序中有以下小部件,它包含一个ImageView,宽度和高度设置为WRAP_CONTENT。根视图又是一个RelativeLayout,宽度和高度设置为WRAP_CONTENT。
我的问题是为什么小部件的顶部和底部有一些填充(标记为黑色)?我希望它是完美的正方形。以下是我的小部件布局。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_battery_2x2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:layout_margin="@dimen/widget_margin"
android:padding="@dimen/widget_padding" >
<ImageView
android:id="@+id/image_widget_arc_battery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff0000"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
@dimen/widget_margin 和 @dimen/widget_padding 为零。
ImageView包含动态生成的位图(宽高为400)。
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
这是我的第一个小部件应用程序 :) 我有点迷茫,无法弄清楚为什么会有这个额外的填充。有人有想法吗?
感谢您的帮助。
【问题讨论】:
标签: android android-layout imageview android-widget android-bitmap