ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Titanium Android中的TextField格式(填充)问题

2019-06-23 21:13:40  阅读:299  来源: 互联网

标签:android formatting textfield titanium-mobile titanium-android


我正面临在Titanium Android中格式化简单文本字段的问题.

问题:我无法查看输入的文本字段输入值.如果我打印日志,它会进入但不可见.在某些设备中,我得到了截止文本.

以下是我的代码:

在我的.js文件中,我有如下文本字段:

var t1 = Titanium.UI.createTextField({
        value : Titanium.App.Properties.getString("userID"),
        left : 130,
        top : 25,
        height : 30,
        width : 140,
        color : 'black',
        font : {
            fontSize : 12
        },
        borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
    });

在我的tiapp.xml文件中:

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
        <application android:theme="@style/Theme.Titanium"/>
        <supports-screens android:anyDensity="false"
            android:largeScreens="false"
            android:normalScreens="false" android:resizeable="false"
            android:smallScreens="false" android:xlargeScreens="false"/>
    </manifest>
</android>

尝试解决方案:我尝试了链接中提供的解决方案:

> TextField formatting issue
> TextField formatting
issue

它表示你需要将TextField的高度设置为“Ti.UI.SIZE”add< supports-screens android:anyDensity =“true”/>在你的tiapp.xml文件中添加< property name =“ti.ui.defaultunit”> dp< / property>在你的tiapp.xml文件中.

如果我将文本字段的高度设置为“Ti.UI.SIZE”,它会显示输入值,但文本字段的高度对于屏幕来说太大了,因为我的特定屏幕中有多个文本字段,并且看起来这个高度太奇怪了.

任何帮助将不胜感激.

谢谢.

更新:在Android 4.4.4和5.0 OS中观察到问题.对于其他,它的工作正常.

解决方法:

最后,我使用在平台文件夹下添加的名为mytheme.xml的自定义主题解决了它 – > android文件夹 – > res文件夹 – > values文件夹 – > mytheme.xml

在mytheme.xml中:

 <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <!-- Define a theme using the AppCompat.Light theme as a base theme -->
    <style name="Theme.MyTheme" parent="@style/Theme.Titanium">
    <!-- For Titanium SDK 3.2.x and earlier, use the Holo.Light or Light theme
    <style name="Theme.MyTheme" parent="@android:style/Theme.Holo.Light">
    -->
        <item name="android:editTextStyle">@style/editText</item>
    </style>

    <style name="editText" parent="@android:style/Widget.EditText">
        <item name="android:textCursorDrawable">@null</item>   
        <item name="android:textColor">#000000</item>
        <item name="android:paddingLeft">10dp</item>
        <item name="android:paddingRight">10dp</item>
        <item name="android:background">#FFFFFF</item>
        <item name="android:gravity">center_vertical</item>
        <item name="android:layout_width">wrap_content</item>
    </style>
</resources>

在tiapp.xml中:

在android标签下:

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest>
        <application android:theme="@style/Theme.MyTheme"/>
</manifest>
</android>

标签:android,formatting,textfield,titanium-mobile,titanium-android
来源: https://codeday.me/bug/20190623/1274335.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有