Resize AnalogClock widget?

I use the built-in AnalogClock widget in my activity layout. I would like to do it more. Setting layout_width and layout_height doesn't seem to matter. Is there an easy way to do this?

<AnalogClock android:id="@+id/analogClock" android:layout_width="500dp" android:layout_height="500dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> 
+4
source share
3 answers

The analog clock by default has a keyboard with the number 231 * 231 in HDPI format. Even mentioning the width and height of AnalogClock is larger, these images are not stretched. To show AnalogClock more, provide your own dial pad and minute hand and hour hand with custom sizes.

  <AnalogClock android:dial="@drawable/your_dial_pad" android:hand_hour="@drawable/your_hour_hand" android:hand_minute="@drawable/your_minutes_hand"/> 
+3
source

You can also use

 android:scaleX="preferedScale" 

and

  android:scaleY="preferedScale" 

with preferedScale = 1,2,3 ... n

+3
source

I found that the previous answers did not work for me. I found a simple solution. Just create your own custom template for the clock background and set the android:dial attribute. You can create the most attractive size. Of course, if you want your watch to look beautiful, you must create two shortcuts within a few hours and minutes. You can simply copy the default drawings to another location and resize them using the image editor:

 <AnalogClock android:id="@+id/AnalogClock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:dial="@drawable/widgetdial_big" android:hand_hour="@drawable/widgethour_big" android:hand_minute="@drawable/widgetminute_big" /> 

if you are working with widgets, you should declare AppWidgetProviderInfo as follows (e.g. 300dip):

 <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:initialLayout="@layout/widget" android:minHeight="300dip" android:minWidth="300dip" android:updatePeriodMillis="0" /> 
0
source

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


All Articles