android – 在圆形磨损装置的角落中对齐元素

android – 在圆形磨损装置的角落中对齐元素,第1张

概述我正在尝试将一个Object对齐到我的round_layout的角落,以获得圆形的 android服装设备. 正如你在这里看到的: 数字时钟将超出界限. 我在google IO 2014上看过android的文档,有些人表示,有一行代码,以便正确对齐对象. 我希望数字时钟位于左上角,但不在屏幕外. 有没有人有建议? 这是XML文件: <RelativeLayout xmlns:android="h 我正在尝试将一个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文件的内容:
<?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”:(从任何一侧偏移)

总结

以上是内存溢出为你收集整理的android – 在圆形磨损装置的角落中对齐元素全部内容,希望文章能够帮你解决android – 在圆形磨损装置的角落中对齐元素所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1134152.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存