Home > Software design >  Why android application shows appbar twice?
Why android application shows appbar twice?

Time:02-14

It shows app name and fragment toolbar even if I use supportActionBar.hide and Theme.MaterialComponents.DayNight.NoActionBar

enter image description here

CodePudding user response:

Add this in style

<style name="Theme.ProjectName.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Then add this in activity tag inside manifest

android:theme="@style/Theme.ProjectName.NoActionBar"

CodePudding user response:

You are adding PlaceholderFragment in your activity. -->

if (savedInstanceState == null) {
getFragmentManager().beginTransaction().add(R.id.your_container, new 
PlaceholderFragment()).commit();
}

Now PlaceholderFragment class is inflating the same layout as your activity as -->

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle 
savedInstanceState) {
View rootView = inflater.inflate(R.layout.main, container, false);
return rootView;
}
  • Related