Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Android in the coordinate system and a method to obtain the coordinates     - Verify the character set on MyCAT (Database)

- Java, boolean operators & =, | = ^ = use (Programming)

- Comparison of C # and Java (Programming)

- Ubuntu modify DNS restart loss problem (Linux)

- Linux Shell Scripting Interview Question (Linux)

- Parse Server supports iOS and Android push messaging (Programming)

- Linux server startup and logon security settings (Linux)

- Linux disk management practices (Linux)

- Read the official GNU Make manual one (chapter 1-2) (Programming)

- Processor in protected mode of protection (Linux)

- Nodejs nano library to handle couchdb: need a timeout (Database)

- How to configure security management services under Linux (Linux)

- Install and manage Java under mac (Linux)

- expdp / impdp use version parameter data migration across versions (Database)

- ActiveMQ configuration Getting Started Tutorial (Server)

- Linux server network penetration testing (Linux)

- Revised OpenJDK Java Memory Model (Programming)

- Use matplotlib scientific drawing in Linux (Linux)

- PostgreSQL transaction model introduction (Database)

- Ubuntu installed Gimp 2.6.11 (stable version) with PPA (Linux)

 
         
  Android in the coordinate system and a method to obtain the coordinates
     
  Add Date : 2016-05-02      
         
       
         
  Ndroid There are two coordinate systems, respectively called Android coordinate system and the view coordinate system. The correspondence also some related methods can get coordinates coordinate system. Only clear these differences, in order not to error, or you can not get the desired effect at the time of implementation.

A, Android coordinate system and the view coordinate system

    (1) Android coordinates

      Let's take a look at Android coordinate system is what it looks like.

Android mobile phone screen coordinates of the top left vertex coordinate origin, from that point to the right of the x-axis positive direction, from that point down the y-axis positive direction. The touch event, use getRawX () and getRawY () method

Get the coordinates of this coordinate system is to coordinate values ​​under the standard.

    (2) the view coordinate system

    android in another coordinate system called the view coordinate system, which describes the child views in the parent view location.

View coordinate system is the upper left corner of the parent view for the origin of coordinates. Corresponding to the origin of the right x axis positive direction, the positive y-axis origin for the downward direction. In touch by

Coordinate getX () and getY () to get the value is the coordinate values ​​for the view coordinate system.


Second, the method of obtaining those coordinates as well as the relative distance

      In the android, there is provided a very rich way to get coordinates and relative distance. However, when using these methods, which must be clear is to obtain the coordinates of the standard.

In order to clear them out of these methods


Description of each method for obtaining a coordinate value or distance is from where to where. Explain the figure there are three black frame, the outermost layer of the cell phone screen,

The intermediate layer is ViewGroup, the innermost is ViewGroup placed in view.

Methods annotated method can be divided into two categories, one is the View provided a method MotionEvent class is provided. Respectively, as follows:

Coordinate View provides access to and from the approach:

getTop () Gets the distance to the top edge of its parent layout view to its top edge

getLeft () to get a view of their own from the left to the left of its parent's layout

getRight () to get a view of their own to the right distance to the left of its parent's layout

getBottom () to get to the bottom of the view itself from the top edge of its parent's layout


MotionEvent method provided:

getX () Gets the distance from the controls on the left click event, that view coordinates

getY () Gets the distance from the event click on the top edge of the control that the view coordinates

getRawX () to get the click event is the distance from the entire screen to the left, that absolute coordinates

getRawY () to get the click event from the entire screen from the top edge of absolute coordinates
     
         
       
         
  More:      
 
- C # DateTime structure common method (Programming)
- Hanoi problem Java Solution (Programming)
- Kernel compile under Debian (Linux)
- Ubuntu Linux use ufw or iptables firewall configuration (Linux)
- Linux platform Oracle MySQL connection (Database)
- Make full use of the Raspberry Pi SD card space (Linux)
- Ubuntu 10.10 install Oracle 10g Installation Guide (Database)
- Install Ubuntu open source drawing program MyPaint 1.2.0 (Linux)
- Tsunami-udp accelerated network transmission (Linux)
- Linux Defensive / mitigate DDOS attacks (Linux)
- Linux awk text analysis tool (Linux)
- Use the DBMS_SCHEDULER package to manage scheduled tasks (Database)
- Storm basic framework for analysis (Programming)
- MySQL 5.6 master-slave replication configuration (Database)
- Android Studio utility plug organize, create sharp artifact (Programming)
- How to install Bugzilla 4.4 on Ubuntu / CentOS 6.x (Linux)
- MySQL common functions summary (Database)
- In Spring AOP example explanation (Programming)
- MySQL high availability cluster fragmentation of deployment uses Fabric (Database)
- VirtualBox installation enhancements let the mouse move and share CentOS 6.4 (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.