I am facing the issue of formatting a simple textfield in Titanium Android.
Problem : I am not able to view the text field input value that I enter. If I print the logs its getting entered but not visible. In some devices I get cut-off text.
Below is my code :
In my .js file I have textfield as follows :
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
});
In my tiapp.xml file :
<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>
Solution tried : I tried the solution provided in the link:
It says that you need to set height of TextField to "Ti.UI.SIZE" + add <supports-screens android:anyDensity="true"/>
in your tiapp.xml file + add <property name="ti.ui.defaultunit">dp</property>
in your tiapp.xml file.
If I set height of textfield as "Ti.UI.SIZE" it shows the input value but the height of textfield becomes too large for the screen because I have multiple textfields in my particular screen and it looks too weird with this height.
Any help will be appreciated.
Thanks.
Update : Issue is observerd in Android 4.4.4 and 5.0 OS.For other, its working fine.
Finally, I solved it using custom theme named mytheme.xml added under platform folder--> android folder --> res folder--> values folder --> mytheme.xml
In 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>
In tiapp.xml:
under android tag :
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.MyTheme"/>
</manifest>
</android>