Use the holidays to summarize the previous things. Let's start with a simple one.The effect is as follows:
I made a screenshot animation. The ratio is a bit incorrect. Let's take a look.
The entire window consists of three parts. The main interface in the middle is a list, the slide interface on the left is a menu, and the slide interface on the right is an edit box. The left menu is half screen, and the right menu is full screen.In the end, I only used the sliding out window on the left, but I
One, custom ViewGroup:1. Choice of construction method:Get some values (some properties or custom properties) that you need to usePublic Custonviewgroup (Context context) {This (context, null);}Public Custonviewgroup (context context, AttributeSet Attrs) {This (context, attrs, 0);}Attrs declared in the layout file, the above two construction methods cannot have custom propertiesPublic Custonviewgroup (context context, AttributeSet attrs, int defstylea
First of all, I've been searching the internet for a long time and I haven't found a way to explain it, so I tried to write it myself.1. I have customized a viewgroup that inherits Relativelayout.The Java code is as follows:/*** Simple Custom three Avatar *@authorm.z*/ Public classMygroupheaderimgextendsRelativelayout { Publicmygroupheaderimg (Context context, AttributeSet attrs) {Super(context, attrs); This. Mcontext =context; MView= Inflate (contex
On the basis of custom ViewGroup (5): http://www.jb51.net/article/100639.htm, add the use of adapter to fit the data, which is more convenient, just use the adapter adapter data and cannot be updated.
Package com.example.libingyuan.horizontallistview.ScrollViewGroup;
Import Android.content.Context;
Import Android.util.AttributeSet;
Import Android.util.DisplayMetrics;
Import Android.util.Log;
Import Android.view.GestureDetector;
Import android.vi
Recently learning to customize ViewGroup, my goal is to make a ListView that you want to scroll, use adapter to populate the data, and use Adapter.notifydatasetchanged () to update the data.
But eat not a fat one (I eat like this but a few years of accumulation of ~ ~ ~ ~ ~ ~ ~ ~ ~), we step by step, this note first write a horizontal layout.
Code:
Package com.example.libingyuan.horizontallistview.ScrollViewGroup;
Import Android.content.Context
The example of this article describes the Android programming rewrite ViewGroup to implement the card layout method. Share to everyone for your reference, specific as follows:
implementation of the effect as shown in figure:
Realize the idea
1. Rewrite onmeasure (int widthmeasurespec, int heightmeasurespec) to set the size of each child view
2. Rewrite OnLayout (boolean changed, int l, int t, int r, int b) to set the position of each child view
Rewrite view:The view class is generally used for drawing operations, overriding its OnDraw method, but it can not contain other components, and there is no AddView (view view) method.Rewrite viewgroup:ViewGroup is a component container that can contain any component, but must override OnLayout (Boolean changed,int l,int t,int r,int B) and onmesure (int widthmesurespec,int Heightmesurespec) method. Otherwise, the add component in ViewGroup is not disp
Let's write a simple demo:A custom control in a layout file that inherits from ViewGroup Mylayout contains a button:Two important ways to override event distribution in a custom control: Onintercepttouchevent and Dispatchtoucheventpublic class Mylayout extends LinearLayout {public Mylayout (context context, AttributeSet Attrs) {Super (context, attrs);} Whether to intercept the delivery of the event, true: Intercept @overridepublic boolean oninterceptt
View class
1. The Android. View class is the most basic UI class. Many UI components on Android inherit this class.
2. These UI components include buttons, textview, and checkbox.
3. How should these UI components be placed?Viewgroup class
1. The preceding UI component is placed in a special view container, which is the viewgroup.
2. viewgroup is used to layout t
Create a linearlayout in the activity, create a scrollhorizon object (scrollhorizon inherited from viewgroup), and call the createlayout function in scrollhorizon to load the myview (inherited from view) object, call the deleteallview function to delete all views.
ScrollhorizonCode:
Public class scrollhorizon extends viewgroup {private context; Public scrollhorizon (context) {super (context); this. co
Custom Controls --- inherit the ViewGroup class method (step 1 step by step effect ---- drag the image left and right + automatic rebound effect)
----------------------- The following effect is only the second step of the overall effect-(currently, drag the image left and right + the rebound effect) --- continue to update the blog -------------------------
Configuration File
Activity_main.xml (not explained, there is only one custom control)
[Html]
a idockingadapterdatasource interface. Of course, you can also use this interface to change the adapter directly, for the sake of completeness of the introduction of the interface is attached here:Public interface Idockingadapterdatasource { int getgroupcount (); int getchildcount (int groupposition); Object getgroup (int groupposition); Object getchild (int groupposition, int childposition); View Getgroupview (int groupposition, Boolean isexpanded, View Convertview,
The custom control provides a getadapter and Setadapter interface for setting the view to scroll (the full screen width is displayed by default for each view) Public class scrollerviewgroup extends viewgroup { Private intScreenHeight;//the phone Screen height Private intCurrentY;//Record the current current Y position Private intstartscrolly;//Record the scroll position of the Y-direction when the finger presses the touch event Private in
The time to learn Android is not short, but has not been seriously read, the previous period of time to see Ask to show the above effect, usually I will use relativelayout and layout_margin* to achieveIn this hack, we'll look at another the creatingThe same type of layout-we ' ll create a custom view-Group. The benefits of using a custom ViewGroupInstead of adding margins by hand in an XML file isThese:A.It ' s easier to maintain if you ' re using It in different activities.B. You can use custom
Sliding with handMany developers are not familiar with the layout of the hand slide, here is an example, see a relativelayout slide displayPrincipleWhether you are sliding with a hand or bouncing into a pop-up animation, you are essentially modifying the location of the view or ViewGroup, which is the Setx () sety () method.
Sliding with hand
Sliding with a hand means that when the user slides on the screen, a piece of layout slides as t
Getchilddrawingorder and Ischildrendrawingorderenabled () are methods that belong to ViewGroup.The Getchilddrawingorder is used to return the index of the current iteration child view. That is, gets the view index that is currently being drawn. If you need to change the order in which the ViewGroup child views are drawn, you need to overload this method.and NeedCall FirstsetChildrenDrawingOrderEnabled(boolean)method to enable the sub-view sorting feat
To implement a streaming layout with less than the width of the wrapped line:Flowlayout.javaPackage Com.jackie.flowlayout;import Android.content.context;import Android.util.attributeset;import Android.view.view;import android.view.viewgroup;/** * Created by Jackie on 8/28/15. */public class FlowLayout extends ViewGroup {public FlowLayout (context context) {This (context, NULL); } public FlowLayout (context context, AttributeSet Attrs) {Super (co
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.