How to calculate the appropriate size of an Android widget?

I have an Android widget containing two buttons. But I have no idea how big my widget should be for different DPIs. According to this , it is easy to calculate, but my widget is not a square, it is a rectangle, how to calculate its size?

My widget-provider.xml is as follows:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="160dip" android:minHeight="72dip" android:updatePeriodMillis="0" android:initialLayout="@layout/main" /> 
+6
source share
2 answers

Since you use dip modules, the system automatically scales the system according to the pixel density. (The widget will always scale to the same physical size, regardless of pixel density). The base density that the system uses for scaling is 160 pixels / inch.

+3
source

I would consider the widget design guide , in particular the widget dimensions section. It sets the size in px, but you should be able to convert them to dp for a given density.

+6
source

Source: https://habr.com/ru/post/896813/


All Articles