That is my version of how to get the transparent Toolbar without shadow in AppBarLayout. The major problem with the above solutions was when I made the toolbar transparent, the shadow was still cast under it. To make the transparent toolbar with the back navigationIcon in Fragment:
layout_transparent_toolbar_fragment.xml:
and in TransparentToolbarFragment:
override fun onCreateView(inflater: LayoutInflater, vg: ViewGroup?, savedInstanceState: Bundle?): View? {
val layout = inflater.inflate(R.layout.layout_transparent_toolbar_fragment, vg, false)
val toolbar = layout.findViewById(R.id.toolbar) as Toolbar
val appBar = layout.findViewById(R.id.general_appbar) as AppBarLayout
appBar.outlineProvider = null
val appCompatActivity = (activity as AppCompatActivity)
appCompatActivity.setSupportActionBar(toolbar)
val actionBar = appCompatActivity.getSupportActionBar()
if (actionBar != null) actionBar!!.setDisplayHomeAsUpEnabled(true)
toolbar.setNavigationOnClickListener { appCompatActivity.finish() }
return layout
}
Actually, the line
appBar.outlineProvider = null
does the job of hiding the toolbar shadow.