WearViewStub

Build Status

alt poster

WearViewStub allow your Android Wear application to use different layouts if running on square, round or moto360 device.

WearViewStub is an alternative implementation of Android Wear WatchViewStub. Instead of Google WatchViewStub, this implementation allways works, even in Fragments of GridViewPager.

Download

In your root build.gradle add

repositories {
    maven {
        url  "http://dl.bintray.com/florent37/maven"
    }
}

In your wear module Download

compile 'com.github.florent37:wearviewstub:1.0.0@aar'

Usage

In your layout, use WearViewStub with wearRectLayout, wearRoundLayout and wearRoundMotoLayout attributes

<com.github.florent37.wearviewstub.WearViewStub
        android:id="@+id/wearViewStub"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:wearRectLayout="@layout/fragment_square"
        app:wearRoundLayout="@layout/fragment_round"
        app:wearRoundMotoLayout="@layout/fragment_round"
        />

And in your code, wait until WearViewStub is inflated to access child views

((WearViewStub)view.findViewById(R.id.wearViewStub)).setOnLayoutInflatedListener(new WearViewStub.OnLayoutInflatedListener() {
                    @Override
                    public void onLayoutInflated(WearViewStub wearViewStub) {
                        //do operations on inflated view
                    }
                });

Dependencies

Based on ShapeWear (by tajchert) - https://github.com/tajchert/ShapeWear.

Community

Looking for contributors, feel free to fork !

Wear

If you want to learn wear development : http://tutos-android-france.com/developper-une-application-pour-les-montres-android-wear/.

Credits

Author: Florent Champigny

Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2015 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.