android - How to set the Watchface in the center of watch -


hy working on developing watch face. know there round , square watch face have designed watch face in such way not crop in round watch . on same time want set @ center of screen .

so tell me how set in center of screen regardless of round , rectangular screen. have done every thing seems start adjusting left side of screen .

i sharing code here 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 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 adjust in center .

if @ sample google provided, analogwatchfaceservice, you'll see center x/y on ondraw via bounds width , height

// find center. ignore window insets that, on round watches // "chin", watch face centered on entire screen, not usable // portion. float centerx = width / 2f; float centery = height / 2f; 

sample: http://developer.android.com/samples/watchface/index.html


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -