Learning android from scratch (FrameLayout frame layout. 14th .)
FrameLayout layout (frame layout) is to open up an area on the screen to fill all the components, but with FrameLayout layout, all the components are placed in the upper left corner of the screen, in addition, all components can be stacked for display.
<frameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >
</frameLayout>
.................................................................. Beautiful cut line ..................................................................
Configure the project directly in the JAVA file without the xml 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 the width and height of FrameLayout for the layout. layoutParams = new FrameLayout. layoutParams (ViewGroup. layoutParams. FILL_PARENT, ViewGroup. layoutParams. FILL_PARENT); // set the height and width of the image FrameLayout. layoutParams imageLayoutParams = new FrameLayout. layoutParams (ViewGroup. layoutParams. MATCH_PARENT, 311); // set the width and height for the button FrameLayout. layoutParams buttonLayoutParams = new FrameLayout. layoutParams (281,173); // set the width and height of the text to FrameLayout. layoutParams textLayoutParams = new FrameLayout. layoutParams (183, 85); ImageView imageView = new ImageView (this); // create an ImageView object imageView. setImageResource (R. drawable. kill); // set the image information layout. addView (imageView, imageLayoutParams); // Add the imageView to the Framelayout layout. Button button = new Button (this); // create the Button object button. setText ("button"); // set the title 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 JAVA file configuration and xml file configuration are the same. You can set the XML layout and Dynamic Layout as needed.
Next prediction: Tablelayout