[TIMOB-3142] Android: Inconsistent Sizing of Tabbed Window with Table and Textfield
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-05-05T15:33:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.7.0, Sprint 2011-12 |
Components | Android |
Labels | android, defect, enterprise, release-1.7.0, reported-1.6.0, rplist |
Reporter | Dawson Toth |
Assignee | Bill Dawson |
Created | 2011-04-15T03:37:55.000+0000 |
Updated | 2011-05-05T15:33:40.000+0000 |
Description
Problem
The height of a table and a text field in a tabbed window is inconsistent when the keyboard pops up. Consider an app with two tabs, and the first tab has a table and a text field on it. Touch into the text field, and the keyboard pops up over the window. The layout of the current tab does not change at all. Switch to the second tab, and then back to the first tab, and everything will have resized to accomodate for the keyboard. This "resize" does not occur if the table is not added to the tab.
Expected Behavior
The tab should either resize or not. The presence of the table should not affect this.
Sample Code
Follow the instructions of the visible text -- "Touch 1st", 2nd, and 3rd. After touching the 1st one, notice the keyboard pops up and the layout is NOT adjusted. Touch 2nd and 3rd, and now notice the tab has been scrunched up.
// create our main window, which is a table with a text field
var mainWindow = Titanium.UI.createWindow({
backgroundColor:'yellow',
title:'Touch Me 3rd'
});
// add a table view -- note that if you comment out this line, the resize issue will disappear!
mainWindow.add(Ti.UI.createTableView());
// add a text field
mainWindow.add(Titanium.UI.createTextField({
width:300,
height:50,
value: 'Touch Me 1st',
backgroundColor:'white'
}));
// add a footer view
mainWindow.add(Ti.UI.createView({
backgroundColor:'#3b5d7c',
bottom: 0,
height: 45
}));
// add our main window to a tab group
var tabGroup = Titanium.UI.createTabGroup();
tabGroup.addTab(Titanium.UI.createTab({
window: mainWindow,
title: 'Touch Me 3rd'
}));
tabGroup.addTab(Titanium.UI.createTab({
window:Titanium.UI.createWindow({
backgroundColor: 'cyan',
title: 'Touch Me 2nd'
}),
title: 'Touch Me 2nd'
}));
tabGroup.open();
Tested On
Titanium SDK version: 1.6.0 (02/10/11 14:34 9db0685...)
Android Epic 4G 2.1
Associated Helpdesk Ticket
http://developer.appcelerator.com/helpdesk/view/72891">http://developer.appcelerator.com/helpdesk/view/72891
(from [73b9a48bfcafd1ca8e5e13b35f39af9a02b705d6]) Give TabGroup the windowSoftInputMode property that windows also enjoy, so that pan/resize behavior can be more predictable. [#3142] https://github.com/appcelerator/titanium_mobile/commit/73b9a48bfcafd1ca8e5e13b35f39af9a02b705d6"> https://github.com/appcelerator/titanium_mobile/commit/73b9a48bfcaf...
(from [0adfd459e883edf0661d4ff259b18c3151f06d51]) Add windowSoftInput property to TabGroup documentation [#3142] https://github.com/appcelerator/titanium_mobile/commit/0adfd459e883edf0661d4ff259b18c3151f06d51"> https://github.com/appcelerator/titanium_mobile/commit/0adfd459e883...
(from [064abfdece16638592e2a60d2d527b4e39a3e2ec]) Fix Ti.UI.Window documentation which erroneously refers to property "softInputMode" -- it's actually "windowSoftInputMode" [#3142] https://github.com/appcelerator/titanium_mobile/commit/064abfdece16638592e2a60d2d527b4e39a3e2ec"> https://github.com/appcelerator/titanium_mobile/commit/064abfdece16...
What you're seeing is Android's non-specific behavior when the
windowSoftInputMode
is not explicitly set. See Android's doc re http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#SOFT_INPUT_ADJUST_UNSPECIFIED"> the unspecified setting, which states "if neither of these [PAN vs RESIZE] are set, then the system will try to pick one or the other depending on the contents of the window".In step 1 of the sample code, Android (for whatever reason) is choosing the "Pan" mode -- the window moves up slightly to (just barely) accomodate the text field when the soft keyboard appears. In step 3, Android decides to use the "Resize" mode -- again, for whatever reason.
Android's pan-and/or-resize stuff gets particularly strange and ornery when a scrollable view -- such as a ListView, which is the native control of the TableView -- is on the Window. You see this in a video I made (no sound):
http://screencast.com/t/PlRIxPUMseei">http://screencast.com/t/PlRIxPUMseei
The video shows a native (non-Titanium) Android application. The blue part near the top of the tabbed window is just a "layout", which is like a "View" in titanium -- it can hold children. Inside it, the grey part is a ListView, which is what Titanium's TableView is based on. When I touch into the text field, the non-specific pan-or-resize that Android does (or doesn't do) totally mucks up, as you see. If I just take out that child ListView, then everything works okay.
Anyway, the point here is that we want to be able to predict how Android will behave, rather than the non-specified behavior. So I've added the
windowSoftInputMode
property toTabGroup
, just like we have it forWindow
. Because "behind" the TabGroup is an Android Window which is responsible for the panning/resizing. So you can think of it as there being 3 windows in play here: the "outside" window which contains the TabGroup (and which you do not specify in Titanium code -- it's just there already when you create the TabGroup), and then the two windows that you created, one each per tab.It's that outside window -- the one holding the entire TabGroup -- that is responsible for resizing/panning. But until just now, Titanium did not have a way for you to tell that outside window which pan/resize mode you want Android to use for the TabGroup.
Now you can specify that. I've added the
windowSoftInputMode
property to TabGroup. So if I modify your code, it will look like this:If you run that, you'll get the "resize" mode right away when you click into the text field.
NOTA BENA: I discovered while working on this that our current, live, production documentation is wrong: It shows - in Ti.UI.Window - that the property name is
softInputMode
, when in fact it iswindowSoftInputMode
.QE Testing:
Take the code from my just-previous comment and run it as your app.js. When you click in the text field, the window should "resize", giving the impression that it compresses and moves the text field up and away from the soft keyboard.