Android wear app displaying rect layout on round watch -
i've got android wear app when run on round watch (moto 360) instead of round layout being displayed rectangular 1 is.
when new wear project created, android studio creates necessary layout files enable automatically load rectangular layout our circular layout appropriate , haven't altered except content of rectangular or round layout files themselves. in particular i have not altered activity_main.xml nor names of rect or round activities nor how loading takes place within activity.
here activity_main.xml:
<?xml version="1.0" encoding="utf-8"?> <android.support.wearable.view.watchviewstub xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/watch_view_stub" android:layout_width="match_parent" android:layout_height="match_parent" app:rectlayout="@layout/rect_activity_main" app:roundlayout="@layout/round_activity_main" tools:context=".mainactivity" tools:deviceids="wear"></android.support.wearable.view.watchviewstub>
here's start of round_activity_main.xml, there's no point in showing all:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" tools:deviceids="wear_round"> <relativelayout android:layout_width="fill_parent"
for completeness here start of rect_activity_main.xml:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".mainactivity" tools:deviceids="wear_square" android:clickable="true"> <relativelayout android:layout_width="fill_parent" android:layout_height="60dp"
and here how layout loaded in activity's oncreate()
setcontentview(r.layout.activity_main); watchviewstub stub = (watchviewstub) findviewbyid(r.id.watch_view_stub); stub.setonlayoutinflatedlistener(new watchviewstub.onlayoutinflatedlistener() { @override public void onlayoutinflated(watchviewstub stub) { ...
everything supposed far can tell, , mentioned should haven't changed android studio created. idea issue be?
start checking out answer, explain how windowinsets
delivered: can use watchviewstub in gridviewpager android wear?
after that:
are using inside of activity?
do have onapplywindowinsetslistener set?
try calling stub.requestapplyinsets() in oncreate.
edit:
from discussion in comments , further investigation. seems need set <item name="windowoverscan">true</item>
on theme windowinsets
dispatched views.
Comments
Post a Comment