0

I need to use part of my activity layout in fragmnent, but I dont know how. If I use overlaying FrameLayout, I will not have access to the elements behind it. And duplicate part of activity_main_layout in several fragments also is not good idea.

1

Community
  • 1
  • 1
  • Probably you should start reading this first: https://developer.android.com/training/basics/fragments/communicating.html – Eselfar Feb 06 '18 at 14:51
  • you will have reference of activity in fragment you could interact with activity ui from that refrence – prat Feb 06 '18 at 14:57

2 Answers2

0

A fragment can't host an activity. Instead you can use nested fragments for this purpose. Fragment Inside Fragment

Dinesh Neupane
  • 382
  • 10
  • 19
  • but if I'll use nested fragment , i'll lose data after parent fragments switching. To be more concrete: It will be something like paint with papercut in the middle. And switching of fragments should change only yellow part(tools buttons), but shouldn't change papercut – Alexander Pidoprigora Feb 06 '18 at 15:21
0

It looks like i need to use fragments with transparent container in the middle