Sid*_*yas 4 formatting android 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
});
Run Code Online (Sandbox Code Playgroud)
在我的 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>
Run Code Online (Sandbox Code Playgroud)
尝试的解决方案:我尝试了链接中提供的解决方案:
它说您需要将 TextField 的高度设置为“ Ti.UI.SIZE ” +<supports-screens android:anyDensity="true"/>在 tiapp.xml 文件中添加+在 tiapp.xml 文件中添加<property name="ti.ui.defaultunit">dp</property>。
如果我将文本字段的高度设置为“ Ti.UI.SIZE ”,它会显示输入值,但文本字段的高度对于屏幕来说变得太大了,因为我的特定屏幕中有多个文本字段,而且这个高度看起来太奇怪了。
任何帮助将不胜感激。
谢谢。
更新:在 Android 4.4.4 和 5.0 操作系统中观察到问题。对于其他,它工作正常。
最后,我使用添加在下面的名为 mytheme.xml 的自定义主题解决了它 platform folder--> android folder --> res folder--> values folder --> 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>
Run Code Online (Sandbox Code Playgroud)
在 tiapp.xml 中:
在 android 标签下:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.MyTheme"/>
</manifest>
</android>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1660 次 |
| 最近记录: |