Frame Layout In Android

Frame Layout is one of most use full layout in android . We use FrameLayout when we want to use fragment in out program.

A fragment is usually us as part of an activity user interface and contribute its own layout. To provide layout for the fragment  you just overwrite the the onCreateView() Method which runs when the fragment is called. In the other word fragment is the one kind of the sub activity.

 

Frame Layout With Example:

Activity_main.xml

  • After that we have to create one other design file for the fragment.

Activity_cell.xml

  • After that we have to create the java class for the fragment and we have to extend this class with Fragment (android.app). In this java class we have to overwrite the onCreateView() method and then call the design file through the inflater.

Fragment.java

  • After we have do some coding in MainActivity.java to replace to our design file with the fragment for which are as below

OutPut

Frame Layout

Leave a Reply

Your email address will not be published. Required fields are marked *