Android Tutorial Material Design 3 - Using a ToolBar as ActionBar

DonManfred

Expert
Licensed User
Longtime User

uniplan

Active Member
Licensed User
Longtime User
I have a problem to display together logo and title.

I have tried using the following code:
B4X:
      ToolBar.Title="MAP"
                ToolBar.SubTitle="Maintenence Automotive Program"
                ToolBar.LogoBitmap = LoadBitmap(File.DirAssets, "MAP-quadrato-jpg.png")

but only appears the logo.

However, if I use only this code:

B4X:
ToolBar.Title="MAP"
ToolBar.SubTitle="Maintenence Automotive Program"

The title and subtitle appears correctly.

What could be the problem?
 

uniplan

Active Member
Licensed User
Longtime User
Can you post an example project?

I made a sample project but I can not attach because the size exceeds the allowable 512Kb.
There is another way to send it?

At the time I will send only the main page and disigner file.
 

Attachments

  • test.zip
    49.7 KB · Views: 480

uniplan

Active Member
Licensed User
Longtime User
1. From the IDE use the Export as zip method. This is usually less then 500kb.

2. You can upload the project on Dropbox (or whatever) and share a link to download.

As attached I send the example project.
 

Attachments

  • testTB1.zip
    55.6 KB · Views: 521

corwin42

Expert
Licensed User
Longtime User
As attached I send the example project.

Logos can have a maximum height of 48dip. Recommended is a height of 32dip for a logo bitmap so you can use this:

B4X:
ToolBar.LogoBitmap = LoadBitmapSample(File.DirAssets, "MAP-quadrato-jpg.png", 32dip, 32dip)
 

corwin42

Expert
Licensed User
Longtime User
Hi

How can I access to added menu by [ Activity.AddMenuItem3 ... ] as a view ?
As Erel said in another thread this is not possible (at least not without some dirty hacks)
Why do you need it?
 

desof

Well-Known Member
Licensed User
Longtime User
Hi, I downloaded the example ACToolBarExample2_0 and it looks fabulous. I have a question about it and it is possible to implement more than one layout content.bal, context1.bal, etc. ?
And if to call one is necessary to close the others?
 

Sapta

Member
Licensed User
Longtime User
Hi @corwin42 and all member,

Thank you for great library,
I'm use this library not on main activity (other activity)
I have problem about color, how fix this problem?

Normal color you can see on the top (Icon B4A Bridge, wifi signal, simcard, bettery 31% and time) with dark blue backgorund color (Main Activity):


How to change this color to the normal in other activity ?



This is our manifest editor:
B4X:
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">#016ac6</item>
        <item name="colorPrimaryDark">#005cad</item>
        <item name="colorAccent">#006fd1</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>
</resources>
)

Thank you
 

corwin42

Expert
Licensed User
Longtime User
The problem are the last two lines in the Theme. You need them for the NavigationDrawer.

Create a second theme (just another <style> block) in the above code with everything except the last two items.
Then use this theme for activities without a navigation drawer (SetActivityAttribute() ).
 

SandroB4A

Member
Licensed User
Longtime User
Thanks corwin42!

I'm updating my old free app to a newer material look, so thanks for your libs (AHViewPager, DesignSupport, MaterialDialogs, Preference..) and for your help.

My donation is the n°50N08049FG327291S
 

fbritop

Active Member
Licensed User
Longtime User
I cannot seem to find if there is any, an event.

When I add menu items to the activity, and using ACToolBarDark as the toolbar, is there any way I can catch the event when the popup menu is clicked?. I need to close a pair of panels when the user opens the popup menu.

Thanks
FBP
 

corwin42

Expert
Licensed User
Longtime User
When I add menu items to the activity, and using ACToolBarDark as the toolbar, is there any way I can catch the event when the popup menu is clicked?. I need to close a pair of panels when the user opens the popup menu.

Sorry for the late answer. I was a bit busy recently.

You can add this event with JavaObject:
B4X:
Sub Activity_Create(FirstTime As Boolean)

        .......

    Dim jo As JavaObject
    jo.InitializeContext
    Dim e As Object = jo.CreateEvent("android.support.v7.app.ActionBar.OnMenuVisibilityListener", "optionsmenu", Null)
    jo = jo.RunMethodJO("getSupportActionBar", Null)
    jo.RunMethod("addOnMenuVisibilityListener", Array As Object(e))
End Sub

Sub OptionsMenu_Event (MethodName As String, Args() As Object) As Object
    If MethodName = "onMenuVisibilityChanged" Then
        If Args(0) = True Then
            Log("Options Menu Opened")
        Else
            Log("Options Menu Closed")
        End If
    End If
    Return Null
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…