1

I want to add a Image icon to be added on top of rootView in FragmentActivity.

I tried doing this:

 ViewGroup rootLayout = (ViewGroup) activity.findViewById(android.R.id.content);
            myView = activity.getLayoutInflater().inflate(R.layout.iconimage, null);
            rootLayout.addView(myView );
            rootLayout.invalidate();

But realised that this only works for AppCompatActivity, and doesn't work for FragmentActivity. As my image cannot be seen.

How can i add Views to Classes that extends FragmentActivity?

nhoxbypass
  • 9,695
  • 11
  • 48
  • 71
Mysterious_android
  • 598
  • 2
  • 9
  • 32

1 Answers1

2

AppCompatActivity is a subclass of FragmentActivity so all features of FragmentActivity will be available in AppCompatActivity.

So making your activity extend AppCompatActivity should hopefully solve your problem.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59