androidwear-oswatchface

Android Wear: What is resources.getDimension(R.dimen.digital_x_offset)


Where does the value associated with this "x_offset" come from or what does it represent? And is it an absolute or relative to width value?

Edit: the default value is 15dp which is about a third of the text size. (info form Clement Amarnath's link: https://developer.android.com/samples/WatchFace/Wearable/res/values/dimens.html)

Edit2: Specifically, I would like to know if there are any cases where a programmer should use this value instead of generating their own values based on screen size and density?


Solution

  • Where does the value associated with this "x_offset" come from

    digital_x_offset value is coming from dimens.xml

    Please refer the below documentation

    https://developer.android.com/samples/WatchFace/Wearable/res/values/dimens.html


    EDIT

    Read this post How to define dimens.xml for every different screen size in android? it provides a good amount of info on dimens.xml


    Offset helps us in placing our frame in the main frame, we can position our frame from the left, right, top or bottom in the main frame/window.

    <dimen name="digital_x_offset">15dp</dimen> This statement of xoffset in dimens.xml means it is the distance from the left side of the screen/frame/window.

    <dimen name="digital_y_offset">80dp</dimen> This statement of yoffset in dimens.xml means it is the distance from the top of the screen.