askquestion
askquestion

Reputation: 169

Android Soft Keyboard Pushing Controls Up Titanium

I can't seem to figure out why the appearance of the soft keyboard whilst editing a text field on Android causes some of my controls to get pushed up the page. Is there a way to stop a view or a button from being moved up? It makes a real mess!

code:

registration = {};
registration.view = Titanium.UI.createView({
top : 0,
backgroundImage : GetfilePath + 'bg.png',
});

registration.init = function(view, name) {
 var Scrolview = Titanium.UI.createScrollView({
    top : viewTop,
    height : Ti.UI.SIZE,
    layout : 'vertical',
    scrollType : 'vertical',
    showHorizontalScrollIndicator : false
});
registration.view.add(Scrolview);

var profileView = Ti.UI.createView({
    top : 10,
    height : 100,
    width : 100,
    //backgroundColor : 'red',
});

Scrolview.add(profileView);

var profileImage = Ti.UI.createImageView({
    image : GetfilePath + 'ProfilePicIcon.png',
});

profileView.add(profileImage);

var chooseprofileView = Ti.UI.createView({
    top : 8,
    width : deviceName == 'tab' ? '92.5%' : '92.5%',
    height : deviceName == 'tab' ? 75 : 60,

});

Scrolview.add(chooseprofileView);

var chooseprofileImage = Ti.UI.createView({
    backgroundImage : GetfilePath + 'ChooseProfilebutton.png'
});

chooseprofileView.add(chooseprofileImage);

var chooseprofileLabel = Ti.UI.createLabel({
    text : 'Choose Profile Pic ',
    color : '#E6E6E6',
    font : {
        fontSize : deviceName == 'tab' ? 19 : 17,
        //fontWeight : 'bold',
        fontFamily : os({
            iphone : 'Helvetica Neue',
            ipad : 'Helvetica Neue',
            ipod : 'Helvetica Neue',
            android : 'helveticaneue-webfont'
        })
    },
});

chooseprofileImage.add(chooseprofileLabel);

//alert(UserDetailsInfoData[0].UserName);

var namesurnametextfield = Titanium.UI.createTextField({
    borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    hintText : 'Name & Surname*',
    backgroundColor : '#32302D',
    color : 'white',
    backgroundImage : 'none',
    keyboardToolbarHeight : 30,
    borderRadius : 10,
    borderColor : '#3F4246',
    borderWidth : 2,
    paddingLeft : 10,
    width : '90%',
    height : 55,
    top : '1%',

    //backgroundColor:'green'
});

Scrolview.add(namesurnametextfield);

var emailtextfield = Titanium.UI.createTextField({
    borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    hintText : 'Email Address*',
    backgroundColor : '#32302D',
    color : 'white',
    backgroundImage : 'none',
    keyboardToolbarHeight : 30,
    borderRadius : 10,
    paddingLeft : 10,
    borderColor : '#3F4246',
    borderWidth : 2,
    width : '90%',
    height : 55,
    top : '1%',
});

Scrolview.add(emailtextfield);

var cellnotextfield = Titanium.UI.createTextField({
    borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    hintText : 'Cellphone Number',
    backgroundColor : '#32302D',
    color : 'white',
    backgroundImage : 'none',
    keyboardToolbarHeight : 30,
    borderColor : '#3F4246',
    borderWidth : 2,
    borderRadius : 10,
    paddingLeft : 10,
    width : '90%',
    height : 55,
    top : '1%',
    keyboardType : Titanium.UI.KEYBOARD_NUMBER_PAD,
});

Scrolview.add(cellnotextfield);

//alert(UserDetailsInfoData[0].UserName);

var displaynametextfield = Titanium.UI.createTextField({
    borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    hintText : 'Display Name*',
    backgroundColor : '#32302D',
    color : 'white',
    backgroundImage : 'none',
    keyboardToolbarHeight : 30,
    borderRadius : 10,
    borderColor : '#3F4246',
    borderWidth : 2,
    paddingLeft : 10,
    width : '90%',
    height : 55,
    top : '1%'
});

Scrolview.add(displaynametextfield);

};

i followed this link but the problem remains same.

ANY Solution?

Upvotes: 1

Views: 1489

Answers (2)

Siddharth_Vyas
Siddharth_Vyas

Reputation: 10100

Try this :

In your tiapp.xml file under android tag add this line of code :

<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >

One of the group of soft input visibility constants, SOFT_INPUT_STATE_ALWAYS_HIDDEN, SOFT_INPUT_STATE_ALWAYS_VISIBLE, SOFT_INPUT_STATE_HIDDEN, SOFT_INPUT_STATE_UNSPECIFIED, or SOFT_INPUT_STATE_VISIBLE.

One of the group of soft input adjustment constants, SOFT_INPUT_ADJUST_UNSPECIFIED, SOFT_INPUT_ADJUST_RESIZE, or SOFT_INPUT_ADJUST_PAN.

Also, check this :

Sample Android example here

Upvotes: 2

Coderji
Coderji

Reputation: 7765

I have never tried titanium before, however in normal Java android development. we add this code to the manifest under the related activity tag.

<activity
android:name="Your-activity-name"
android:windowSoftInputMode="adjustPan"
...

I read that there is a Custom AndroidManifest.xml in Titanuim 3.x.. Hope this works for you.

Upvotes: 1

Related Questions