The implementation of graphics for Android development
Four days ago after the first class of Android, really is a face Meng, although brother Bear said and Java is similar, but the package and the package of the conversion between what the Devil Ah!!! But four days of learning and operation down, I think that android than Java learning to be more interesting, but also more concise, it is not like Java to write many classes, all the implementation is in those classes, Java learning is like an ascetic, what to self-made it! But the study of Android is different, it is more like a rich second generation, the father of the Foundation to you to play well, want to use to take is, in order to save your strength, parents are categorized to put the framework there, you put your own ideas installed up! Android is very convenient, but like every family has a complete set of prison system to strengthen the status of the family, such as Android is also a lot of big undergarment festival .... Let's take a look at how I know the rules, and how to implement it.
There are many difficult and complicated diseases everywhere, especially here:
1th: like Java, first you need a form, Java is usually JFrame, and Android is activity.
Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); //get the interface we need to display on AndroidSetcontentview (R.layout.activity_main); //Get the login button on the login screenButton Butlogin = (button) This. Findviewbyid (R.id.butlogin); //instantiating an object of the Loginlistener event-handling classLoginlistener LL =NewLoginlistener ( This); //to add an action listener to the event source object Butlogin Specifies the object of the event handling class LLButlogin.setonclicklistener (LL); } @Override Public BooleanOncreateoptionsmenu (Menu menu) {getmenuinflater (). Inflate (R.menu.draw, menu); return true; }}
"Activity_main" refers to the form style you set in layout:
Note: LinearLayout represents a linear layout (including vertical layout and horizontal layout)
orientation= "Vertical" represents a vertical layout, orientation= "Horizontal" represents a horizontal layout
Android:gravity= "Top" (buttom, left, right, center_vertical, fill_vertical, Center_horizontal, Fill_horizontal, center , fill, clip_vertical,
Clip_horizontal) controls the alignment of controls in the layout.
android:padding= "20DP" This place controls the distance from the border of all controls in this linear layout
<linearlayout android:layout_width= "match_parent" android:layout_height= "Wrap_content" Android : orientation= "Horizontal" > <textview android:layout_width= "wrap_content" android:layou t_height= "Wrap_content" android:hint= "@string/t"/> <edittext android:id= "@+id/editname "Android:layout_width=" match_parent "android:layout_height=" Wrap_content "android:hint= "@string/E"/> </LinearLayout> //This paragraph indicates that the account text box and the input box are on a horizontal line<LinearLayout android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:orientation= "Horizontal" > <TextView android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:hint= "@string/t1"/> <EditText Android:id= "@+id/editpassword"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:hint= "@string/e1"Android:password= "true"/> </LinearLayout>
The difference between padding and margin
Padding constrains the distance the control or layout displays from the bounding rectangle, compressing it inward along the vertical border, and the larger the padding, the smaller the content display control;
Margin this is the distance extending outward along the vertical border, which means to add a certain distance to the control of the blank edge, the display effect only with the value of positive and negative correlation, and other element bounds independent.
DD NJ x
The implementation of graphics for Android development