0

Hy I am working on developing the watch face. As we know that there are round and square watch face so i have designed the watch face in such a way that it does not get crop in round watch . but on the same time I want to set it at the center of the screen .

so tell me how to set it in a center of screen regardless of round and rectangular screen. I have done every thing but its seems that it start adjusting itself from the left side of screen .

I am sharing my code here for Rectangular layout

    <?xml version="1.0" encoding="utf-8"?>

<android.support.wearable.view.BoxInsetLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"

    app:layout_box="all"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:padding="15dp">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="5dp"

        app:layout_box="all">


        <com.example.bilal.cutomanalogclockdemo.AnalogClock1
            android:id="@+id/clock"  style="@style/clock"
            xmlns:android="http://schemas.android.com/apk/res/android"
            />


    </FrameLayout>


</android.support.wearable.view.BoxInsetLayout>

and this is for round layout

 <android.support.wearable.view.BoxInsetLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"

    app:layout_box="all"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:padding="15dp">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="5dp"
        app:layout_box="all">


        <com.example.bilal.cutomanalogclockdemo.AnalogClock1
            android:id="@+id/clock"  style="@style/clock"
            xmlns:android="http://schemas.android.com/apk/res/android"
            />


    </FrameLayout>


</android.support.wearable.view.BoxInsetLayout>

now please tell me how to adjust it in a center . thanks

  • You should take a look at the WatchFace API: http://developer.android.com/training/wearables/watch-faces/index.html. What you are doing is absolutely not compliant with the API and you won't be able to release it. – Nicolas POMEPUY Dec 16 '14 at 14:08
  • I read that and they said your design should be able to display on both kind of devices , So I just want a helping code that would easily let me to display it in the center of watch of any kind. – Abdul Salam Ali Dec 17 '14 at 06:44
  • If you read carefully, you will see that's it's not possible to inflate views from xml in the watchface API, so your code is not relevant. – Nicolas POMEPUY Dec 17 '14 at 07:35
  • so can you tell me how to do it? as reading those documents I really do not understand how to do this ???? – Abdul Salam Ali Dec 17 '14 at 10:33
  • and I am not using the watch face api – Abdul Salam Ali Dec 17 '14 at 10:34

1 Answers1

1

If you look at the sample Google provided, AnalogWatchFaceService, you'll see that they get the center x/y on the onDraw via the bounds width and height

// Find the center. Ignore the window insets so that, on round watches with a
// "chin", the watch face is centered on the entire screen, not just the usable
// portion.
float centerX = width / 2f;
float centerY = height / 2f;

Sample: http://developer.android.com/samples/WatchFace/index.html

bboyjacob
  • 91
  • 2