android - How to add width and height of fragment programatically? -


i want add fragment mainactivity when adding fragmnet it, covering full width , height of main activity. how set width , height of fragment wrap content programatically, not using xml.

here code of have far:

mainactivity.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:id="@+id/rekl"     android:layout_height="match_parent"     tools:context="com.example.ankit.fragment2.mainactivity">   </relativelayout> 

mainactivity.java

public class mainactivity extends appcompatactivity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);  setcontentview(r.layout.activity_main);  fragment3 f=new fragment3();  fragmentmanager m=getfragmentmanager(); fragmenttransaction t=m.begintransaction();     t.add(r.id.rekl,f,"frag");             t.commit();              }             } 

you can this

 fragmentmanager m = getfragmentmanager();         fragmenttransaction t = m.begintransaction();         viewgroup.layoutparams params = f.getview().getlayoutparams();         params.height = 900;         f.getview().setlayoutparams(params);         t.add(r.id.frame, f, "frag");         t.commit(); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -