Android Question Same code with different results?

D

Deleted member 103

Guest
Hi,

Can anyone tell me why these different height?

HTC-Samsung.png
 

Attachments

  • HTC-Samsung.zip
    10 KB · Views: 182
D

Deleted member 103

Guest
Maybe due to the SW buttons? S4 has HW buttons.

They haven't different height, but hw buttons on htc one cover the height

It unfortunately has nothing to do with it, it is only due to the different "Activity Attributes".
Main-Code:
B4X:
#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: True
#End Region

Activity-Test1-Code:
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

If the "Activity Attributes" are equal in both activity, then there are no problems.
Now I do not know whether it is a B4a error or a general Android error is, perhaps Erel can say better.

PS: I never use the designer :)
This is a mistake! The designer works well.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is a known issue (https://www.b4x.com/android/forum/threads/wrong-layout.42447/#post-256896).

The activity size reported by the OS is incorrect when the second activity first appears.

As a workaround:
1. Set the layout animation to 0.
2. Add this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("frmchatroom")

   lblStatusbar.Text="Test"
   lblStatusbar.Background=phone1.GetResourceDrawable(17301653)

   ime1.Initialize("ime1")
   ime1.AddHeightChangedEvent

End Sub

Sub IME1_HeightChanged (NewHeight As Int, OldHeight As Int)
   Log(NewHeight & ", " & OldHeight)
   If NewHeight < OldHeight And OldHeight - NewHeight < 50dip Then
     Activity.Finish
     StartActivity(Me)
   End If
End Sub
It will cause the activity to be recreated after the correct height is set.
 
Upvote 0
Top