Reputation: 57583
I'm facing a newbie problem designing a widget.
My widget should have 4 ImageViews and a TextView as header.
When I put 3 ImageViews this is the correct result:
After adding the fourth image my widget gets truncated:
As you can see last image (that is 64x64 like others) is shrinked.
Why?
I've just red this link, but even if I try to set fixed width to 320dip, my widget is not correct.
Here is widget layout:
<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>
Upvotes: 1
Views: 311
Reputation: 48871
Turning my comment / suggestion to answer as you asked.
Try setting android:layout_width="64dip" for the 3 ImageView elements and see if that fixes it.
I'm not 100% sure why it fixed it but I suspect it has something to do with the screen size of your emulator and the actual size of the images (in real pixels) compared to the dip
.
For further information, this from the Dev Guide...Supporting Multiple Screens and in particular the section describing how different sizes and densities work...Range of screens supported
Glad to help.
Upvotes: 1
Reputation: 745
And I can't answer your AppWidgetProviderInfo, so I'll post it here:
Here you find all https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo.html
Upvotes: 0
Reputation: 745
Use
android:layout_width="64dip"
or
android:layout_width="0dip" android:layout_weight="1"
on every ImageView
Upvotes: 0