Tags: github tle window remove line MoS CEP Pass source
3.1 Android Control architecture
Measurement of 3.2 view
Drawing of 3.3 view
Measurement of 3.4 ViewGroup
Drawing of 3.5 ViewGroup
3.6 Customizing View
3.6.1 to expand the existing space
3.6.2 Creating a composite control
3.6.3 rewrite view to achieve new space
3.7 Custom
Related articlesAndroid View System (i) Views coordinate systemAndroid View System (ii) six ways to implement view swipeAndroid View System (iii) property animationAndroid View System (iv) parsing from source code scrollerPrefaceThree years ago wrote the event distribution mechanism article but not very good, so write again, about the event distribution mechanism of the article has a lot, but I hope this is the most concise, the most understandable article.1. How to handle click eventslevel of v
into XML.----------------------------------------------A. If the software interface is implemented by coding, you need to put the unchanged part in XML, which makes it easier to modify the interface later.B. But the interface performance should be better achieved through coding.C. The software must comply with the MVC mode.------------------------------------------------------4. The following is the example source code of the interface implemented through encoding.A. Create an android project:
-generated method stub
// Set listview to display
(Mymusicactivity) mycontext). setlistviewlinearlayoutvisible (false );
// Galleryvisible is hidden
(Mymusicactivity) mycontext). setgalleryvisible (true );
}
});
Mystorage. setid (2); // Set ID to 2
// Set the button for the local current directory
Myimagebutton myimagebuttonfoldernow = new myimagebutton (context, R. drawable. style+mymusic_details, buttontext );
Relativelayout. layoutparams lp1 = new relativ
the setContentView () method, while the setContentView () method is not implemented by the Activity. The following are android. app. code in the Activity: 1 public void setContentView (View view, ViewGroup. layoutParams params) {2 getWindow (). setContentView (view, params); 3 initActionBar (); 4} while getWindow () returns an android. app. window object, which is the mWindow member variable assigned in attach. Android. app. Window is an abstract cla
Dialog Box customization: Java code implementation of relative LayoutCreate alertdiaglog
Window window = DLG. getwindow ()
Create layout. The code is relative layout.
Load layout, load related space, and set the location of related controls
The Code is as follows:
Int bgimageviewid = 10; int iconimageviewid = 11; int textviewid = 12; int buttonokid = 13; int buttoncancelid = 14; int srcimageviewid = 15; Final alertdialog DLG = new alertdialog. builder (this ). create (); DLG. show (); window = D
There are only two main characters in touch event distribution: ViewGroup and view. The activity's touch event is actually called the ViewGroup touch event inside it, and can be treated directly as ViewGroup.View within the ViewGroup, ViewGroup can also be in other viewgroup
);
return true;
}
return false;
}
Inside executes Monclicklistener.onclick (this), the OnClick () function that backs up the binding listener.
Key points:What is the difference between Ontouch and ontouchevent and how to use it?For:When the view control accepts a touch event, if the control is bound to the Ontouchlistener listener and the control is enable, then the Ontouch () method is executed, and if true, the touch event is consumed, no longer passed down, and if false, Then
This cottage a new version of the list of QQ slide Delete, the last article on the slide to delete the QQ, speculated that the principle is ListView itself each item there is a button, but the general state of the hidden off, detect the left slide when the event pops up hidden button, However, when you switch button state, you give the button a show and hidden animation. This listview is implemented below.
The first difficulty is to get a view of its item through ListView, for
which all views are inherited from view and the view is laid out through various layout components (ViewGroup). ViewGroup also inherits from view. All UI controls, such as button, TextView, are inherited from view, and all layout controls such as Relativelayout, container controls, such as ListView, inherit from ViewGroup. So, the main thing about our event oper
There are three events related to touch events in Android:Public Boolean dispatchtouchevent (motionevent eV): transmits the touch event to the target view (which can be your own ).Public Boolean onintercepttouchevent (motionevent eV): defined in viewgroup to intercept the transfer of touch events.Public Boolean ontouchevent (motionevent event): Touch event processing function.
Let's talk about two methods of event transmission:Tunnel mode: pass d
OnLayout source code process logic (ANDROID custom view), onlayoutandroid
Reprint please indicate this article from the blog of the big glutinous rice (http://blog.csdn.net/a396901990), thank you for your support!
Introduction:
In the custom view, it is actually very simple. You only need to know the three steps:
1. Measurement -- onMeasure (): Determines the size of the View.
2. Layout -- onLayout ():Determine the position of the View in the ViewGroup
I am a rookie, I do not have that level of research on the drawing process of view, but after a variety of consulting predecessors Daniel's information or blog know that the drawing process of the view is divided into Onmeasure,onlayout,ondraw three important processes, Let's take it as a conclusion to guide your study of Android graphics, and take a lot less detours. The following is affixed to their own experience and experience, the wrong place to welcome criticism, to learn together.Before o
LinearLayout organizes a view into one row or one column. Child views can be arranged vertically or horizontally. To learn how LinearLayout works, first consider the typical mail. xml file.
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: orientation = "vertical">
Android: layout_width = "fill_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/hello"/>
In main. xnl, the root node element is Each View and
rollback stack in the activity records the occurrence of the fragment event. By pressing the return button, roll back the stack to allow the user to return a fragment event (navigation backward ).
When the fragment you add is part of the activity layout, it resides in a ViewGroup of the activity's view structure, and fragment defines its own layout. You can define fragment in the activity layout file to insert it into your activity, like
Or add
Transcriptmode of the list. The following options are available:
//(1) Disabled disables Transcriptmode, which is also the default value;
(2) Normal when the new entry is added to the list and is ready to be displayed, the list automatically slides to the bottom to display the latest entries;
(3) Alwaysscroll
2. Xml attributes inherited from ViewGroup
The
android:addstatesfromchildren//sets whether the
In Android, any control can be scrolled because there are scrollto () and Scrollby () methods in the view class, as shown in the following illustration:
The primary role of the two methods is to move the view/viewgroup to the specified coordinates and save the offset. Other than that:
Mscrollx represents the offset coordinates of the x-axis directionmscrolly represents the offset coordinates of the Y axis direction
Both of these methods are used
organically, and write a control is a combination of multiple controls, typically a custom layout, you can use a class to inherit a layout. This layout contains multiple controls.3. Create a new control from scratch. Start drawing controls directly from view, ViewGroup4. also do not forget, there is a good thing in a project we may need to use the same layout design, if it is written in an XML file, the code is very redundant, and very poor readability, so we can put the same layout of the cod
have done a news client, and a music player, the internship is doing is a voice mail client, is developing a Sina Weibo client.1. News client is one of my works in the University of Software Development Contest, it is a mobile phone application, used to display news information, users can view and comment on the news.2. Jane, Mei Music player is my own research and development of a music player, in the spirit of want to do a simple, beautiful music player for their own use.3. Language mailbox i
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.