"deviceType": ["tv" ]
"deviceType": ["wearable" ]
"deviceType": ["tv","wearable" ]
public void onStart(Intent intent) {
super.onStart(intent); LayoutConfig config = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT); myLayout.setLayoutConfig(config); ShapeElement element = new ShapeElement(); element.setRgbColor(new RgbColor(255, 255, 255)); myLayout.setBackground(element); Text text = new Text(this); text.setLayoutConfig(config); text.setText("Hello World"); text.setTextColor(new Color(0xFF000000)); text.setTextSize(50); text.setTextAlignment(TextAlignment.CENTER); myLayout.addComponent(text);super.setUIContent(myLayout); }
if(DeviceInfo.getDeviceType().equals("tv")) { ... ...} else if(DeviceInfo.getDeviceType().equals("wearable")) { ... ...}
public void onStart(Intent intent) { super.onStart(intent); LayoutConfig config = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT); myLayout.setLayoutConfig(config); ShapeElement element = new ShapeElement(); element.setRgbColor(new RgbColor(255, 255, 255)); myLayout.setBackground(element); Text text = new Text(this); text.setLayoutConfig(config);if(DeviceInfo.getDeviceType().equals("tv")) { // 运行在TV上执行的代码 text.setText("华为智慧屏"); text.setTextColor(new Color(0xFFFF0000)); text.setTextSize(200); } else if(DeviceInfo.getDeviceType().equals("wearable")) {// 运行在Wearable上执行的代码 text.setText("华为智能手表"); text.setTextColor(new Color(0xFF0000FF)); text.setTextSize(50); } text.setTextAlignment(TextAlignment.CENTER); myLayout.addComponent(text); super.setUIContent(myLayout); }
- EOF -javascript
1. 比Python更牛的语言有吗?看我用元类(metaclass)花式建立Python类java
2. 见鬼!导入Python模块执行了全部代码,你不知道__name__变量是什么意思吗?
web
3. 连Python产生器(Generator)的原理都解释不了,还敢说Python用了5年?编程
4. 牛掰了!鸿蒙与Android完美融合,将鸿蒙设备当Android设备用json
关注「极客起源」公众号,加星标,不错过精彩技术干货
ui
本文分享自微信公众号 - 极客起源(geekculture)。
若有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一块儿分享。this