Android Question CustomDialog and Animation - Height < 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I use CustomDialog in one of my Apps and it seems to work just fine with Animation if the Anchors are set to Top and Left. Screen animates from Top/Left to Bottom/Right

If I change both the Anchors to BOTH I get the following error:
Height < 0 is not allowed

Any reason why having them set to BOTH (trying to make the animation appear from the middle out) would produce this error?


Thanks
BobVal


Update: Even if I set the Animation Duration to Zero, I still get the same message when the anchors are set to BOTH.
 
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Not the answer I was hoping for. I've stopped using BetterDialogs in most of my programs so I guess it is time to remove it from this one.

Thanks for the reply.

BobVal
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Not the answer I was hoping for.
It's not a real problem. You can do the same thing (and a lot more) with the designer scripts. For example, if the width of your dialog is 60%x, you can place your view at 20dip from the right edge with the code: MyView.Right = 60%x - 20dip.

I've stopped using BetterDialogs in most of my programs
Out of curiosity, why?
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I put up dialogs that have rounded corners but there is a frame that is square around it. Just does not look as nice as it should.

And the dialog margin does not always appear the way I want (you once answered the reason for this, can't remember what you said), but in either case I've learned different ways of doing things and I can get the look I want and have it look that way on MY different devices (Samsung phone S3 and Samsung Galaxy Tab-3)
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I put up dialogs that have rounded corners but there is a frame that is square around it. Just does not look as nice as it should.
Indeed, and that cannot change. I use an AlertDialog in Java (as the other dialog libraries) and it has always a rectangular frame.

And the dialog margin does not always appear the way I want (you once answered the reason for this, can't remember what you said), but in either case I've learned different ways of doing things and I can get the look I want and have it look that way on MY different devices (Samsung phone S3 and Samsung Galaxy Tab-3)
Note that this margin was in the former version of the library. I removed it in the new version.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Just tried the new version.

Now, I have to assume I am doing something wrong. Because it is showing my dialog with about 10dip extra to the right of where my dialog ends.
If I pass a width that is 10dip less then my width it makes the right size box but my dialog is now chopped by 10dip.

I do not understand why it shows a bigger frame rectangle then the width specified?

Or why I see the dialog frame if I set the background color to Transparent (shouldn't the frame disappear?)
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Now, I have to assume I am doing something wrong. Because it is showing my dialog with about 10dip extra to the right of where my dialog ends.
If I pass a width that is 10dip less then my width it makes the right size box but my dialog is now chopped by 10dip.

Due to the frame of the AlertDialog, the maximum usable width for your dialog is 100%x - 30dip, as in the demo. The value that you use to set the body width is exactly the same as the one you have to use in designer scripts to place or size the views, so there's no surprise. The layout can be perfect on all devices.
Note that this AlertDialog is the standard dialog of Android. If you want to respect the guidelines of the OS, it's the dialog to use.

Or why I see the dialog frame if I set the background color to Transparent (shouldn't the frame disappear?)
Your custom dialog is inside an AlertDialog. The AlertDialog is opaque. You cannot make it transparent in B4A.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Sorry I am still confused. My screen is no were near 100%x - 30dip see picture below

Payouts - Bruce Harris -2.png


In area I marked with the dotted yellow rectangle you will see where my dialog ends and the dialog frame from as you say the AlertDialog ends.

I just do not understand why they do not end at the same spot. Please do not get upset your knowledge is probably far beyond mine.


To get rid of this, I have take to just showing my screen it self (with a blank transparent panel to disable outside touches)
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Defines

B4X:
PrivatesPI_MainPanelAsPanel
PrivatesPI_PanelAsPanel
PrivatesPI_PlayerNameAsLabel
PrivatesPI_AvgHcpBPAsLabel
PrivatesPI_EntriesAsLabel
PrivatesPI_CostAsLabel
PrivatesPI_ProfitLossAsLabel
PrivatesPI_TotalPlacesAsLabel
PrivatesPI_1stPlacesAsLabel
PrivatesPI_2ndPlacesAsLabel
PrivatesPI_3rdPlacesAsLabel
PrivatesPI_4thPlacesAsLabel
PrivatesPI_5thPlacesAsLabel
PrivatesPI_TotalWinningsAsLabel
PrivatesPI_1stWinningsAsLabel
PrivatesPI_2ndWinningsAsLabel
PrivatesPI_3rdWinningsAsLabel
PrivatesPI_4thWinningsAsLabel
PrivatesPI_5thWinningsAsLabel
PrivatesPI_PlayingAsLabel
PrivatesPI_GoBackAsButton


Dim BD As BetterDialogs

Stripped down Code to display

B4X:
Sub wInfo_Click
Dim PlayerInfoPanel AsPanel

PlayerInfoPanel.Initialize("PlayerInfoPanel")
PlayerInfoPanel.LoadLayout("splayerinfo")

Dim DialogPrefs AsBD_CustomDlgParams
DialogPrefs.Initialize
DialogPrefs.BodyHeight = sPI_MainPanel.Height
DialogPrefs.BodyWidth = sPI_MainPanel.Width
DialogPrefs.DialogBody = PlayerInfoPanel
DialogPrefs.Background = Colors.Transparent
DialogPrefs.DialogGravity = Gravity.CENTER
BD.CustomDialog(DialogPrefs, "sPI_GoBack")
End Sub


NOT sure why the code above is not formatting right, I am copying it right out of B4A v4.0
Somehow the tabs are not translating.

I omitted all the code that fills in the dialog before display - surely you do not need to see that
Hope this helps.
 

Attachments

  • splayerinfo.bal
    14.4 KB · Views: 106
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Defines

B4X:
PrivatesPI_MainPanelAsPanel
PrivatesPI_PanelAsPanel
PrivatesPI_PlayerNameAsLabel
PrivatesPI_AvgHcpBPAsLabel
PrivatesPI_EntriesAsLabel
PrivatesPI_CostAsLabel
PrivatesPI_ProfitLossAsLabel
PrivatesPI_TotalPlacesAsLabel
PrivatesPI_1stPlacesAsLabel
PrivatesPI_2ndPlacesAsLabel
PrivatesPI_3rdPlacesAsLabel
PrivatesPI_4thPlacesAsLabel
PrivatesPI_5thPlacesAsLabel
PrivatesPI_TotalWinningsAsLabel
PrivatesPI_1stWinningsAsLabel
PrivatesPI_2ndWinningsAsLabel
PrivatesPI_3rdWinningsAsLabel
PrivatesPI_4thWinningsAsLabel
PrivatesPI_5thWinningsAsLabel
PrivatesPI_PlayingAsLabel
PrivatesPI_GoBackAsButton


Dim BD As BetterDialogs

Stripped down Code to display

B4X:
Sub wInfo_Click
Dim PlayerInfoPanel AsPanel

PlayerInfoPanel.Initialize("PlayerInfoPanel")
PlayerInfoPanel.LoadLayout("splayerinfo")

Dim DialogPrefs AsBD_CustomDlgParams
DialogPrefs.Initialize
DialogPrefs.BodyHeight = sPI_MainPanel.Height
DialogPrefs.BodyWidth = sPI_MainPanel.Width
DialogPrefs.DialogBody = PlayerInfoPanel
DialogPrefs.Background = Colors.Transparent
DialogPrefs.DialogGravity = Gravity.CENTER
BD.CustomDialog(DialogPrefs, "sPI_GoBack")
End Sub


NOT sure why the code above is not formatting right, I am copying it right out of B4A v4.0
Somehow the tabs are not translating.

I omitted all the code that fills in the dialog before display - surely you do not need to see that
Hope this helps.
The main problem of your dialog is that it uses fixed values. You don't define the width and height of the dialog according to the display size of the device, so it can be displayed properly only on your device (and similar screens). The views are not sized or placed dynamically so what I get on my current test device is unusable (25% of your layout is off screen). If you set DialogPrefs.BodyWidth to 100%x - 30dip, that won't change anything as nothing is dynamic in your layout. It's not just a problem with BetterDialogs, it's a general problem of layout building.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Currently beyond my knowledge.

Can you point me somewhere so I can understand how to fix this problem.
Doing that is not very hard and I'm not sure it really deserves a dedicated tutorial (I don't know if one exists). In your designer script, place and size your views; that's all. Look at the BetterDialogs demo. I do that in the script of corps.bal. When Anchors did not exist (it's a recent addition), scripts were the only way to properly design a layout.
 
Upvote 0
Top