B4J Question Moving Elements

barx

Well-Known Member
Licensed User
Longtime User
How do you move / re-size elements / views in code?

I have the following code

B4X:
    Log(SearchAccordion.Top)
    SearchAccordion.Top = SearchAccordion.Top - mnuSearch.Height
    Log(SearchAccordion.top)

The log shows that the .Top value does change but the nothing on the screen moves.

Project added for help

Basically I want to see the accordion move up when the Seach Close button is clicked.

my ideal effect is to fade out, move, fade in using setAlphaAnimated but if I have fade out and fade in after, nothing happens.

Guess that is 2 questions, my bad, lol
 

Attachments

  • DMS Order.zip
    4 KB · Views: 200

Daestrum

Expert
Licensed User
Longtime User
try this for question #1
To move up
B4X:
Dim jo As Javaobject = SearchAccordian
jo.RunMethod("setTranslateY",Array(-mnuSearch.Height))

To move back down when search opens
B4X:
Sub mnuSearch_MouseClicked (EventData As MouseEvent)
mnuSearch.SetLayoutAnimated(500, 0, mnuSearch.Top, mnuSearch.Width, mnuSearch.Height)
Dim jo As JavaObject = SearchAccordian
jo.RunMethod("setTranslateY",Array(0.0))
End Sub

note: translate is relative to the original position which is why offset 0.0 puts it back in original position.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I recommend you to create the main layout with the internal designer. You can add a pane in the internal designer and then load a fxml layout to this pane with the Accordion.

The reason that the accordion doesn't change its position is that the anchors are defined. You need to either change the anchors at runtime or disable them.
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
I recommend you to create the main layout with the internal designer. You can add a pane in the internal designer and then load a fxml layout to this pane with the Accordion.

The reason that the accordion doesn't change its position is that the anchors are defined. You need to either change the anchors at runtime or disable them.

The main reason I used SceneBuilder is, one of the first elements in the layout is a horizontal split pane, something that is not available in b4j. I think i would have to do many imports to get the results. The trickiest part seems to be getting things to move / position. Quite comlicated with min/max/pref height/width and left/top ect
 
Upvote 0
Top