我正面臨在Titanium Android中格式化簡(jiǎn)單文本字段的問(wèn)題.
問(wèn)題:我無(wú)法查看輸入的文本字段輸入值.如果我打印日志,它會(huì)進(jìn)入但不可見(jiàn).在某些設(shè)備中,我得到了截止文本.
以下是我的代碼:
在我的.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./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的高度設(shè)置為“Ti.UI.SIZE”add< supports-screens android:anyDensity =“true”/>在你的tiapp.xml文件中添加< property name =“ti.ui.defaultunit”> dp< / property>在你的tiapp.xml文件中.
如果我將文本字段的高度設(shè)置為“Ti.UI.SIZE”,它會(huì)顯示輸入值,但文本字段的高度對(duì)于屏幕來(lái)說(shuō)太大了,因?yàn)槲业奶囟ㄆ聊恢杏卸鄠€(gè)文本字段,并且看起來(lái)這個(gè)高度太奇怪了.
任何幫助將不勝感激.
謝謝.
更新:在Android 4.4.4和5.0 OS中觀察到問(wèn)題.對(duì)于其他,它的工作正常. 解決方法: 最后,我使用在平臺(tái)文件夾下添加的名為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標(biāo)簽下:
<android xmlns:android="http://schemas./apk/res/android">
<manifest>
<application android:theme="@style/Theme.MyTheme"/>
</manifest>
</android>
來(lái)源:https://www./content-4-262501.html
|