Android Question Showkeyboard changes edittext size between portrait and landscape layouts.

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

I have an App with a portrait and a landscape layout (not variants)
The edittext size and position is defined in the script of each layout. In portrait the edittext is as defined by the designer script. In Landscape the edittext is all the screen that is not occupied by the keyboard. [Wrong]

I see that this question has been asked before on the forum but unfortunately the answer was a link to a thread on edittext colours, not sizes.

As usual I am hoping that someone is familiar with the issue and has a simple answer. If it is a bit more challenging I will start taking screen shots, uploading code etc.
Looking forward to the response that says "You idiot, everyone knows ......... ".

Regards Roger
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
that this is how EditTexts behave by default in landscape.

You can solve it with: https://www.b4x.com/android/forum/threads/password-not-working-on-alternate-field.104478/post-654868

The first part is a joke of course.......


Thanks Erel,
I'm glad to see you are in good humor with all that is happening with B4X.
It looks like you have the solution, it works in some instances but not others. I think that is me using Callsubdelayed for some reason in the past. That's the weekend's job.

Is It best to Dim jo1 as javaobject in Sub Globals
and jo1 = Rdisplay
jo1.RunMethod............
in Activitycreate?

or everything just before Showkeyboard each time? I've seen both used.

Busy the next few days but I will post the outcome when I get it all working.

Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
No need to use CallSubDelayed. You just need to call it once after you load the layout.

Thanks Erel,

The callsubdelayed is an old timing issue, I have replaced that with a sleep(250) before kb.ShowKeyboard(Rdisplay). It was only a couple of instances that this was a problem but I used the sleep function in all cases just to be cautious.

I tried calling it just once after Load Layout [seems sensible to me] but the original problem returned in some cases. I found calling it each time before calling the keyboard works every time, don't know why.

The code below demonstrates how I have made the damn thing work. Many thanks to Erel.

Regards Roger

Toggle Portrait and Landscape:
Sub Globals
'...... stuff'
Private jo1 As JavaObject
'...... stuff'
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ScrnOrientVal = StateManager.GetSetting2("ScrnOrientVal", 1)
    If ScrnOrientVal = 0 Then
        Activity.LoadLayout("landscape")       
        'jo1 = Rdisplay
        'jo1.RunMethod("setImeOptions", Array(Bit.Or(33554432, 6)))  'IME_FLAG_NO_FULLSCREEN | IME_ACTION_DONE
    Else
        Activity.LoadLayout("portrait")
    End If
    Phone1.SetScreenOrientation(ScrnOrientVal)
    
    '...... stuff'
    
    jo1 = Rdisplay
    
    '...... stuff'
    
End Sub

Sub FLabelSet
'Brings up the keyboard to allow a Function Label to be applied to F0-F15.
'Called by Formula_click and CheckSelectionPGM

    Rdisplay.ForceDoneButton = True
    jo1.RunMethod("setImeOptions", Array(Bit.Or(33554432, 6)))  'IME_FLAG_NO_FULLSCREEN | IME_ACTION_DONE
    Sleep(250)
    kb.ShowKeyboard(Rdisplay)                                    'FLabelSet

    FMask.BringToFront
    BtnExit.BringToFront
    Idisplay.Text = "Enter F" & FNum & " Label"
    Rdisplay.RequestFocus
    Rdisplay.Text = ""
    RFocus = 1
    DoneAction = 1   
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…