Android 未定义上边距时钛合金屏幕中的UI错误

Android 未定义上边距时钛合金屏幕中的UI错误,android,titanium,titanium-mobile,titanium-alloy,titanium-android,Android,Titanium,Titanium Mobile,Titanium Alloy,Titanium Android,嗨,我是钛应用程序的新手,正在学习合金开发方法 我在index.xml中写道: <Alloy> <Window class="container"> <TextField id="title" hintText="Title"></TextField> <TextArea id="description" hintText="Description"></TextArea> &

嗨,我是钛应用程序的新手,正在学习合金开发方法

我在index.xml中写道:

<Alloy>
    <Window class="container">
        <TextField id="title" hintText="Title"></TextField>
        <TextArea id="description" hintText="Description"></TextArea>
    </Window>
</Alloy>
<Alloy>
    <Window class="container" layout="vertical">
        <TextField hintText="TextField 1" class="inputs" />
        <TextArea hintText="TextArea 1" class="inputs" />
        <TextField hintText="TextField 2" class="inputs" />
        <TextArea hintText="TextArea 2" class="inputs" />
    </Window>
</Alloy>

但在Android Emulator中预览时,它会在屏幕中央显示重叠的文本字段。但在默认情况下,它应该从顶部开始,然后自动从顶部获得一些相对的余量


现在显示的是:i.imgur.com/KOZUP6K.png

默认情况下,Alloy将绝对布局应用于视图/窗口的子组件。要克服此问题,只需指定如下垂直布局:

<Alloy>
    <Window class="container" layout="vertical">
        <TextField id="title" hintText="Title"></TextField>
        <TextArea id="description" hintText="Description"></TextArea>
    </Window>
</Alloy>

您必须通过为
布局
属性指定一个类似于
垂直
水平
的值来覆盖窗口子项的默认对齐方式,有关详细说明,请检查此项

您还可以为文本字段指定相同的类,并为该类指定一个
top
值,然后尝试并在UI中检查结果

index.xml:

<Alloy>
    <Window class="container">
        <TextField id="title" hintText="Title"></TextField>
        <TextArea id="description" hintText="Description"></TextArea>
    </Window>
</Alloy>
<Alloy>
    <Window class="container" layout="vertical">
        <TextField hintText="TextField 1" class="inputs" />
        <TextArea hintText="TextArea 1" class="inputs" />
        <TextField hintText="TextField 2" class="inputs" />
        <TextArea hintText="TextArea 2" class="inputs" />
    </Window>
</Alloy>

谢谢你的回答,但是布局是居中的,而且光标在对焦时不会闪烁。谢谢你的回答,扎巴迪。你们能告诉我为什么光标在对焦时不闪烁,默认文本颜色是灰色的吗。或任何方法来更改它们2。当焦点默认蓝色已经很好时。但是当没有对焦时,我们可以把蓝色的下划线颜色添加到黑色或其他颜色吗?如果你想让我下载任何主题,那么我也下载了。这是我在android上编译默认颜色时遇到的错误,在iOS上编译默认颜色是黑色,您可以通过在tss文件中添加颜色在
top:10,
之后进行编辑,记住在每个属性后添加逗号,添加此行-->
color:'black'
,它也采用十六进制颜色。在iOS上,您可以通过赋予属性borderStyle值来编辑文本字段的样式,例如,
borderStyle:Ti.UI.INPUT\u borderStyle\u ROUNDED,
,在android上,您可以用数字编辑
borderWidth
borderRadius
属性,以实现您想要的效果,我建议您阅读正在使用的任何UI元素的文档,检查文本字段-->