我正在尝试将一个Object对齐到我的round_layout的角落,以获得圆形的
android服装设备.
正如你在这里看到的:
正如你在这里看到的:
数字时钟将超出界限.
我在google IO 2014上看过android的文档,有些人表示,有一行代码,以便正确对齐对象.
我希望数字时钟位于左上角,但不在屏幕外.
有没有人有建议?
这是XML文件:
<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=".MyActivity"
tools:deviceids="wear_round">
<DigitalClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text"
android:textSize="20sp"/>
</RelativeLayout>
编辑:
对于圆形活动,我的xml布局文件现在看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234567890"
app:layout_Box="top"/>
</android.support.wearable.view.BoxInsetLayout>
正如您所看到的,我尝试使用BoxInsetLayout,但仍然是输出如下:
虽然我用过
app:layout_Box="top"
TextView超出了屏幕的界限.我有什么监督?
解决方法
根据Google IO 2014上显示的内容,您应该使用BoxInsetLayout:
Check out this video< - 大约6:04 您可以在DelayedConfirmation示例代码中查看BoxInsetLayout的用法.以下是main_activity.xml文件的内容:
Check out this video< - 大约6:04 您可以在DelayedConfirmation示例代码中查看BoxInsetLayout的用法.以下是main_activity.xml文件的内容:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/grey"
app:layout_Box="top">
[...]
</LinearLayout>
</android.support.wearable.view.BoxInsetLayout>
您可以将app:layout_Box设置为以下值:left | top | right | bottom或all.你可以在你的情况下使用所有内容,然后所有内容都将保留在每一方的框内.当app在方形手表上运行时,将忽略此布局的效果.
编辑:
我刚刚测试了你发布的代码为“不起作用”:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234567890"
app:layout_Box="all"/>
</android.support.wearable.view.BoxInsetLayout>
有活动:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
我已经告诉过你要使用layout_Box中的all值,但即使是top也可以使用:
app:layout_Box =“top”:(仅从顶部偏移)
app:layout_Box =“all”:(从任何一侧偏移)