Hi Sahil ,
I have used Scroll View behind all text-box & Instead of giving transition to text-box, i pointed scroll-view & the prob is solved…
Here is all that you want , It will automatically scroll down when user submit or press key back :
[lua]
local widget = require( “widget” )
–==========================declaration=========================================
local nameTxtFld,mobileTxtFld,emailTxtFld
local scrollView
_W=display.contentWidth
_H=display.contentHeight
_actualH=display.actualContentHeight
_X=display.contentCenterX
_Y=display.contentCenterY
–===============================================================================
local nameTxtFldListener=function( event )
if ( “began” == event.phase ) then
scrollView:scrollToPosition
{
y = -_Y*0.80,
time = 800,
}
elseif( “submitted” == event.phase ) then
if(event.target.id==1)then
native.setKeyboardFocus(mobileTxtFld)
elseif (event.target.id==2)then
native.setKeyboardFocus(emailTxtFld)
else
native.setKeyboardFocus(nil)
end
end
return true
end
local emailTxtFldListener=function( event )
if ( “began” == event.phase ) then
scrollView:scrollToPosition
{
y = -_Y*0.80,
time = 800,
}
elseif( “submitted” == event.phase ) then
native.setKeyboardFocus( nil )
scrollView:scrollToPosition
{
y = -0,
time = 800,
}
end
return true
end
local createDesign=function()
local profileGroup=display.newGroup()
profileGroup=display.newGroup()
------------------------------Username & Paswd textFld----------------------
local txtWidth=_W*0.80
local txtFldHgt=_H*0.05
-----------------------------------------
nameTxtFld=native.newTextField(_X,_Y,txtWidth,txtFldHgt)
nameTxtFld.placeholder=“Name”
nameTxtFld.anchorY=0
nameTxtFld.id=1
nameTxtFld:addEventListener( “userInput”,nameTxtFldListener )
profileGroup:insert(nameTxtFld)
mobileTxtFld=native.newTextField(_X,nameTxtFld.contentBounds.yMax+20,txtWidth,txtFldHgt)
mobileTxtFld.placeholder=“Mobile”
mobileTxtFld.inputType = “number”
mobileTxtFld.anchorY=0
mobileTxtFld.id=2
mobileTxtFld:addEventListener( “userInput”,nameTxtFldListener )
profileGroup:insert(mobileTxtFld)
emailTxtFld=native.newTextField(_X,mobileTxtFld.contentBounds.yMax+20,txtWidth,txtFldHgt)
emailTxtFld.placeholder=“Email”
emailTxtFld.anchorY=0
emailTxtFld.id=3
emailTxtFld:addEventListener( “userInput”,emailTxtFldListener )
profileGroup:insert(emailTxtFld)
------------------------------------------
local registerBtn = display.newRoundedRect(_X, emailTxtFld.contentBounds.yMax+30,_W*0.8, _H*0.05, 12 )
registerBtn:setFillColor(0/255,112/255,186/255)
registerBtn.anchorY=0
profileGroup:insert(registerBtn)
local btnTxt = display.newText(profileGroup,“REGISTER”,_X,registerBtn.contentBounds.yMin+registerBtn.contentHeight*0.5, _font, _fontSize )
----------------------------
return profileGroup
end
local createScrollView=function()
local scrollViewListener=function()
if(scrollView.y>0)then
native.setKeyboardFocus( nil )
scrollView:scrollToPosition
{
y = -0,
time = 800,
}
end
end
--------------------------------------
local txtGrp=createDesign()
--------------------------------------
scrollView = widget.newScrollView
{
top =_actualH*0.10,
left = 0,
width = _W,
height = _H*0.95,
bottomPadding= 200,
backgroundColor = { 240/255,239/255,245/255}
}
-----------------------
scrollView:setIsLocked(true, “horizontal” )
scrollView:setIsLocked(true, “vertical” )
--------------------------------------------
scrollView:addEventListener(“tap”,scrollViewListener)
scrollView:insert(txtGrp)
end
–==============================================================================
createScrollView()
[/lua]
-Assif