指定布局移动和磨损模块 [英] Specifying layouts for mobile and wear modules

查看:192
本文介绍了指定布局移动和磨损模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建从头开始一个新项目,为移动(的minSdkVersion 9)和磨损(的minSdkVersion 20)模块,然后我想知道如何指定磨损轮布局和戴方(我需要玩的WatchViewStub类有点?)设备。就像,我知道得到的数据从手持设备发送到磨损,但如何配置,使应用程序的磨损轮运行,耐磨方形布局(尤其是仅使用XML文件),因此?

I created a new project from scratch for both mobile (minSdkVersion at 9) and wear (minSdkVersion at 20) modules, and I was wondering how to specify layouts for wear-round and wear-square (do I need to play around with the WatchViewStub class a bit?) devices. Like, I am aware that the data gets sent from the handheld to the wear, but how can I configure it so the app runs on the wear-round and wear-square layouts (particularly using only the XML files) accordingly?

这是我的手机\\ ... \\ activity_main.xml中:

Here's my mobile\...\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"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Hello mobile world!"
        android:id="@+id/textView"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
</RelativeLayout>

至于磨损模块下的布局,一切都默认(我没有修改任何东西),让包括,但不限于,通过WatchViewStub类的实现充气,XML的圆形和方形屏幕,应该输出你好广场的世界!和你好一轮世界!,分别和等。

As for the layouts under the wear module, everything is defaulted (I didn't modify anything), so that includes, but not limited to, the inflater via the implementation of the WatchViewStub class, XMLs for round and square screens that should output "Hello Square World!" and "Hello Round World!", respectively, and etc.

下面是我不变的磨损\\ ... \\ MainActivity:

Here's my untouched wear\...\MainActivity:

package dpark.gameoflife;

import android.app.Activity;
import android.os.Bundle;
import android.support.wearable.view.WatchViewStub;
import android.widget.TextView;

public class MainActivity extends Activity {
    private TextView mTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
        stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
            @Override
            public void onLayoutInflated(WatchViewStub stub) {
                mTextView = (TextView) stub.findViewById(R.id.text);
            }
        });
    }
}

...然后这就是我从磨损虚拟仿真得到:

... And then here's what I get from the wear virtual emulators:

在这里输入的形象描述

为什么我的虚拟圆上面模拟器不会出现圆的?

Why does my round virtual emulator above not appear round?

在这里输入的形象描述

谢谢,我非常AP preciate它。

Thanks, I greatly appreciate it.

推荐答案

资源预选赛布局全面布局方在SDK水平23.要定位为圆形和方形显示不同的布局同期水平,只介绍了,你想要么使用 WatchViewStub BoxInsetLayout ,既这里记录。

Resource qualifiers layout-round and layout-square were only introduced in SDK level 23. To target earlier levels with different layouts for round and square displays, you'll want to either use WatchViewStub or BoxInsetLayout, both documented here.

根据您的发布时间表,不过,你也可以只针对SDK 23的耐磨侧。 23是大多数手表已经和谷歌曾表示,所有易损设备将很快得到它(ISH)。

Depending on your release schedule, though, you could also just target SDK 23 on the wearable side. 23 is on most watches already, and Google has said that all Wear devices will be getting it soon(ish).

和为您全面展示模拟器......方有没有很好的解释,但他们只是做的时候。重启几次,删除并重新创建它,如果你有,并最终将其应自行解决。

And as for your round emulator displaying square... there's no good explanation, but they just do that sometimes. Restart it a couple of times, delete and recreate it if you have to, and eventually it should sort itself out.

这篇关于指定布局移动和磨损模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆