Android小部件被截断

Android小部件被截断,android,android-widget,Android,Android Widget,我在设计小部件时遇到了一个新手问题。 我的小部件应该有4个图像视图和一个文本视图作为标题。 当我放置3个ImageView时,这是正确的结果: 添加第四个图像后,我的小部件被截断: 如您所见,最后一张图像(与其他图像一样为64x64)已缩小。 为什么? 我只是红色,但即使我尝试将固定宽度设置为320dip,我的小部件也不正确 以下是小部件布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

我在设计小部件时遇到了一个新手问题。
我的小部件应该有4个图像视图和一个文本视图作为标题。
当我放置3个ImageView时,这是正确的结果:

添加第四个图像后,我的小部件被截断:

如您所见,最后一张图像(与其他图像一样为64x64)已缩小。
为什么?
我只是红色,但即使我尝试将固定宽度设置为320dip,我的小部件也不正确

以下是小部件布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:orientation="vertical">
    <TextView android:layout_width="fill_parent"
        android:layout_height="20dip" android:text="@string/app_name"
        android:gravity="center_vertical|center_horizontal"
        android:background="#4E7FAB" android:textColor="#FFA10E"
        android:textStyle="bold" />
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/status_layout" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:background="@android:color/darker_gray">

        <ImageView android:id="@+id/widget_usage" android:src="@drawable/usage_none"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:clickable="true" />
        <ImageView android:src="@drawable/div" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView android:id="@+id/widget_behaviour" android:src="@drawable/beh_drop"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:clickable="true" />
        <ImageView android:src="@drawable/div" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView android:id="@+id/widget_calls" android:background="@drawable/missed_calls_zero"
            android:layout_width="64dip" android:layout_height="64dip"
            android:textColor="@android:color/black" android:gravity="center_vertical|center_horizontal"
            android:textStyle="bold" android:text="0" />
        <ImageView android:src="@drawable/div" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView android:id="@+id/widget_contacts" android:src="@drawable/contacts"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:clickable="true" />
    </LinearLayout>
</LinearLayout>

使用

在每个图像视图上使用


在每个ImageView上,我都无法回答您的AppWidgetProviderInfo,因此我将在此处发布它:

在这里你可以找到所有的

我无法回答您的AppWidgetProviderInfo,因此我将在此处发布:

在这里你可以找到所有的
将我的评论/建议按您的要求回答

尝试为3个ImageView元素设置android:layout_width=“64dip”,看看是否可以解决这个问题

我不能100%确定它为什么会修复它,但我怀疑它与您的模拟器的屏幕大小以及与
dip
相比的图像的实际大小(以实际像素为单位)有关

有关更多信息,请参阅《开发指南》。。。特别是描述不同尺寸和密度的部分


很高兴为您提供帮助。

按照您的要求回答我的评论/建议

尝试为3个ImageView元素设置android:layout_width=“64dip”,看看是否可以解决这个问题

我不能100%确定它为什么会修复它,但我怀疑它与您的模拟器的屏幕大小以及与
dip
相比的图像的实际大小(以实际像素为单位)有关

有关更多信息,请参阅《开发指南》。。。特别是描述不同尺寸和密度的部分


很高兴提供帮助。

尝试设置3个
ImageView
元素的
android:layout\u width=“64dip”
,看看这是否能解决问题。AppWidgetProviderInfo的内容是什么,特别是minWidth的值是多少?@MisterSquonk:是的,这很有效!!无论如何,我试图更改我的AppWidgetProviderInfo xml,最终我能够使其正常工作:为每个图像视图设置
android:layout\u width=“wrap\u content”
,为ProviderInfo设置
android:minWidth=“262dip”
,工作完成。无论如何,我真的不明白这种行为的原因。如果你把你的评论作为回答,我会接受的。谢谢你帮我!!:)请尝试为3个
ImageView
元素设置
android:layout\u width=“64dip”
,看看这是否可以解决问题。AppWidgetProviderInfo的内容是什么,尤其是minWidth值?@MisterSquonk:是的,这很有效!!无论如何,我试图更改我的AppWidgetProviderInfo xml,最终我能够使其正常工作:为每个图像视图设置
android:layout\u width=“wrap\u content”
,为ProviderInfo设置
android:minWidth=“262dip”
,工作完成。无论如何,我真的不明白这种行为的原因。如果你把你的评论作为回答,我会接受的。谢谢你帮我!!:)
android:layout_width="64dip"
android:layout_width="0dip" android:layout_weight="1"