Closed luizmota82 closed 2 years ago
The app will have a native app bar and a native bottom nav so I need to hide the toolbar used by Turbo.
The toolbar provided in the default TurboWebFragment
layout includes a native toolbar, so I'm not quite sure why you'd want to add your own? However, if you'd like to customize the default layout, it's trivial. Here's the default layout:
https://github.com/hotwired/turbo-android/blob/main/turbo/src/main/res/layout/turbo_fragment_web.xml
You can copy this file to your app and change it however you'd like. Just make sure to keep the <include layout="@layout/turbo_view" />
element. Then, override onCreateView()
in your web fragment:
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.my_web_fragment, container, false)
}
I have also thought about using a custom layout for the TurboWebFragment, but how do I then link the web view in this custom layout to the TurboWebFragment session?
As long as you include the @layout/turbo_view
in your customized layout, the library will find the necessary views by their (static) resources IDs.
If you'd like to inflate a menu for the default toolbar that the library provides, you can see an example in the demo app:
toolbarForNavigation()?.inflateMenu(R.menu.my_menu)
// Or get a reference to the existing toolbar by its resource ID:
view?.findViewById<Toolbar>(R.id.toolbar)?.inflateMenu(R.menu.my_menu)
Thank you the include resolved my issue 👍
I'm trying to create an app which has part of it run by a rails website, and the other part native. The app will have a native app bar and a native bottom nav so I need to hide the toolbar used by Turbo.
When trying to access the toolbar via
I am unable to hide the toolbar, what I end up with is a panel, the size of the android action bar, with a
colorPrimary
background. I have also tried to override the above method by providing the id for the native toolbar and style it and provide the app bar menus to circumvent this but I am unable to assign a menu to the app bar.Given that the only area where turbo will be used for this app is in this one destination of the bottom nav I decided to have the app bar native.
I have also thought about using a custom layout for the
TurboWebFragment
, but how do I then link the web view in this custom layout to theTurboWebFragment
session?