SupportChartFragment onCreateView is final



I’m using a SupportChartFragment and want to add a header and/or footer to my chart. I wanted to extend SupportChartFragment and wrap its return value from onCreateView (in another view that would contain the header as well) but I noticed that method is marked as final.

Is there any workaround for adding a fixed header/footer to a chart fragment?



A workaround for this is to override this instead:

public void onViewCreated(final View view, Bundle savedInstanceState)

Depending on what library you’re using for fragments (in my case, the support library) you’ll need to figure out how to add stuff. For the support library, view will be a FrameLayout that contains the actual chartView. So for adding a footer, you need to inject an additional LinearLayout that will have your header or footer and add this FrameLayout view as a child (don’t forget to remove it from its current parent)