All Projects → florent37 → Wearviewstub

florent37 / Wearviewstub

Licence: apache-2.0
Display different layout on Android Wear Square / Round / Moto 360

Programming Languages

java
68154 projects - #9 most used programming language

WearViewStub

Build Status Android Weekly Android Arsenal

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 wear module Download

compile 'com.github.florent37:wearviewstub:[email protected]'

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

Pictures by Logan Bourgouin

Follow me on Google+

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].