The difference between fill_parent, match_parent and wrap_content:
- Fill_parent: The component will be forced to be expanded to fill as much space as possible within the layout unit.
- Wrap_content: The view will be forced to expand to show all content, roughly equivalent to setting the AutoSize property of Windows controls to true.
- match_parent:android2.2 in Match_parent and fill_parent is a meaning. Two parameters meaning, match_parent more appropriate, So starting from 2.2 two words can be used, then if you consider the use of the lower version you need to use fill_parent.
Second, the interface update problem:
For security reasons, a child thread is not allowed to modify the UI of the main thread in Android, so if you want to modify the main thread through the child threads, the UI can only be passed handler. Example:
1. The main thread receives the parameter value passed by the child thread, based on the value to determine how to modify the UI. (assuming that the main thread is in the activity named Mactivity)
public class MyHandler extends handler{
Public MyHandler () {
}
Public MyHandler (Looper L) {
}
public void Handlemessage (Message msg) {Super.handlemessage (msg); Bundle B = Msg.getdata (); Switch (msg.what) {case 0: int shoudao = b.getint ("index"); System.out.println ("value from child thread =" + Shoudao); break; Case ...; }
}
}
2. The child thread passes a message to the main thread.
public void Sendhandlermessage () {
Message msg = new Message ();
Bundle B = new bundle ();//Store data
Msg.what = 0;//Sets the What value of MSG, the main thread is based on that value to determine who received the message
B.putint ("index", 15455);
Msg.setdata (b);
MActivity.myHandler.sendMessage (msg);
}
Iii. Common GetWindow (). SetFlags Method:
Set up a form full screen
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
The setup form is always lit
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Set the background blur for a form
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Iv. Common methods:
- Gets the width/height of the screen: Getwindowmanager (). Getdefaultdisplay (). GetWidth (), Getwindowmanager (). Getdefaultdisplay (). Gethigth ().
V. Dynamically change the width and height of the layout:
Hypothesis: 1. The changed layout for main_leftlist_layout
2. The property of its parent layout is linearlayout (Special note)
Then set the width and height of the code as follows:
Main_leftlist_layout.setlayoutparams (New Linearlayout.layoutparams (LinearLayout.LayoutParams.WRAP_CONTENT));
VI. Add a new layout to your code:
Layout rules R1, R2
Add two objects in LAYOUT1 IMG, TV
IMG follows rules R1,TV follows rules R2
ImageView img = new ImageView (activity.this);
TextView TV = new TextView (activity.this);
Linearlayout.layoutparams r1 = new Linearlayout.layoutparams (new Layoutparams (18, 18));
Linearlayout.layoutparams r2 = new Linearlayout.layoutparams (New Layoutparams (LinearLayout.LayoutParams.WRAP_ CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
Layout1.addview (IMG, R1);
Layout1.addview (TV, r2);
Seven. Pass parameters between two activity:
- Activity1 passes parameters to Activity2, which is defined in Activity1:
String str = "Hello";
Bundle info = new bundle ();
Info.putstring ("Chuanzhi", str);
Intent Intent = new Intent (activity1.this, Activity2.class);
Intent.putextras (info);
StartActivity (Intent);
This way, Activity1 passes hello through Chuanzhi to Activity2. Where any type of data can be passed.
- Activity2 receives the parameter Chuanzhi, then it is defined in Activity2:
Intent Intent = Getintent ();
Bundle data = Intent.getextras ();
String Shoudao = (string) data.getserializable ("Chuanzhi");
System.out.println ("Activity1" string is: "+ Shoudao);
Viii. Related dialog:
1. Set the width, height, alignment, etc. of the dialog:
Dialog Start_dialog = new Dialog (context, r.style.mydialog);
window window = Start_dialog.getwindow ();
Start_dialog.setcanceledontouchoutside (TRUE);
Start_dialog.setcontentview (Take_audio_start);
Windowmanager.layoutparams LP = Window.getattributes ();
Lp.width = 200;
Lp.height = 300;
lp.gravity = Gravity.bottom;
Window.setattributes (LP);
Start_dialog.show ();
Nine, the difference between Putextras and Putextra in intent:
Public Intent PutExtra (String name, parcelable value)
Set method Intent.putextra ("AAA", "bbbb");
Get Method This.getintent (). Getcharsequenceextra ("AAA")
Public Intent Putextras (Bundle extras)
Setup method
BUNDLE BD = new bundle ();
Bd.putstring ("AAA", "bbbb");
Intent.putextras (BD);
Get method
Bundle bd=this.getintent (). Getextras ();
Bd.getstring ("AAA"));
Summary: The band S has to bind the data through a bundle
Android Development Summary (i)