Dialogfragment
Issue background:
General app Development will encounter the need for pop-up windows, but dialogfragment default style is with the title bar, but this is often not needed, so we can set dialogfragment style
1 @Override 2 Public void onCreate (Bundle savedinstancestate) {3 Super . OnCreate (savedinstancestate); 4 SetStyle (dialogfragment.style_no_title, 0); 5 }
However, after this setting, you will find that the height and width of the dialog is not what you want, how you set the height and width of the root view is useless, when the Android system ignores the height and width of the root view,
So I take a trickery approach is that the root view is set to Relativelayout or Framelayout, then the first view is space or view, this view is set to the width and height you want, as follows
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent" >5 6 <Space7 Android:layout_width= "Wrap_content"8 Android:layout_height= "Wrap_content"9 Android:minheight= "248.5DP"Ten Android:minwidth= "250DP" /> One A <LinearLayout - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" the android:gravity= "Center" - android:orientation= "vertical" - Android:paddingbottom= "39DP" - Android:paddingleft= "20DP" + Android:paddingright= "20DP" - Android:paddingtop= "30DP" > + A </LinearLayout> at - </Relativelayout>
Issue background:
Sometimes we need to use nested fragment, but the use of nested fragment has a limitation, that is, only through the dynamic addition of code, not by adding in the XML, the official website explains,
Note: You cannot inflate a layout to a fragment when that layout includes a <fragment> . Nested fragments is only supported if added to a fragment dynamically.
So the question is, if fragment's container view is linearlayout, what if I set the margin between the fragment?
Solution:
My method is to set the margin of the view in the OnStart or Onresume method of the child fragment, but it is necessary to judge that the current fragment is the number of children of container.
Android Development Experience-fragment related