Framelayout layout (frame layout) is the creation of an area on the screen to fill all the components, but using the Framelayout layout puts all the components in the upper-left corner of the screen, and all the components can be stacked for display.
<?xml version= "1.0" encoding= "Utf-8"? ><framelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" match_parent " android:layout_height=" match_parent "> < ImageView android:id= "@+id/imageview1" android:layout_width= "match_parent" android:layout_height= " 322DP " android:src=" @drawable/kill "/> <button android:id=" @+id/button1 " android:layout_ Width= "240DP" android:layout_height= "107DP" android:text= "button"/> <textview Android:id= "@+id/textview1" android:layout_width= "154DP" android:layout_height= "62DP" android: text= "Large Text" android:textappearance= "? Android:attr/textappearancelarge"/> </framelayout >
..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... ... .. ....... There is no beauty in the dividing line ... ..... ..... ..... ..... ..... .......-.....-......................
do not need an XML file to configure the project directly in the Java file
Package Com.example.framelayout;import Android.os.bundle;import Android.app.activity;import android.view.ViewGroup ; Import Android.widget.button;import Android.widget.framelayout;import Android.widget.imageview;import Android.widget.textview;public class Mainactivity extends Activity {@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Framelayout layout = new Framelayout (this),//set width and height for layout framelayout.layoutparams layoutparams = new Framelayout.layoutparams (viewgroup.layoutparams.fill_parent,viewgroup.layoutparams.fill_parent);// Set the height and width of the picture framelayout.layoutparams imagelayoutparams = new Framelayout.layoutparams (ViewGroup.LayoutParams.MATCH_ PARENT, 311);//set width and height for buttons framelayout.layoutparams buttonlayoutparams = new Framelayout.layoutparams (281, 173);// Set the width and height of the text framelayout.layoutparams textlayoutparams = new Framelayout.layoutparams (183); ImageView ImageView = new ImageView (this);//Create ImageView Object Imageview.setimageresource (R.drawable.kill);/Set Picture information Layout.addview (ImageView, imagelayoutparams);//Add ImageView to framelayout layout button button = New button (this) ;//Create button Object Button.settext ("button");//Set Caption Layout.addview (button, buttonlayoutparams);// Add the button to the Framelayout layout TextView textview=new TextView (this);//Create TextView Object Textview.settext ("TextView");// Set the title Layout.addview (TextView, textlayoutparams);//Add TextView to Framelayout super.addcontentview (layout, Layoutparams);//Add Framelayout to content}}
You can see that the effects of using the Java file configuration and the XML file configuration are the same, the way the XML layout and the dynamic layout can be set according to your own needs
forecast for next section: Table layout tablelayout