Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Android in the coordinate system and a method to obtain the coordinates     - Use smartmontools view the health status of hard disk (Linux)

- About the replication of JavaScript (Programming)

- The Java development environment to build under Ubuntu 14.04 (Linux)

- Source code is installed MySQL 5.6.28 (Database)

- What is the Docker (Linux)

- C ++ Replication Control: Assignment operators and destructors (Programming)

- SSH without password (Linux)

- Setting the RedHat9 Intrusion Detection System (Linux)

- Oracle Linux 6.4 installed Oracle 11gR2 + RAC + ASM (Database)

- GDB remote connections RX Probe online debug program (Programming)

- To disable the function by pressing Ctrl-Alt-Del to restart the system in RHEL / CentOS 5/6 (Linux)

- Ubuntu 14.04.02 LTS startup items erroneous writing / dev / sda1 (win 7 loader) Repair (Linux)

- Python implementation restart the router (Programming)

- Getting Started with Linux system to learn: how to check the version of SSH on Linux (Linux)

- ActiveMQ memory settings and flow control (Linux)

- Linux shell in back quotes (`) Application (Linux)

- Let your PHP 7 faster the Hugepage (Linux)

- Memcached installation, configuration and monitoring (Server)

- Ubuntu resolve sudo: source: command not found error (Linux)

- Import and export myloader accelerate mydumper (Database)

  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
- Java development specifications summary (Programming)
- Why is better than Git SVN (Linux)
- Shell scripts to copy all directories under the current directory of a certain type of file to the same directory (Linux)
- PostgreSQL using the system cache to improve operational efficiency (Database)
- CentOS boot image to achieve semi-automatic installation (Linux)
- How to use the Vault secure password storage and API key (Linux)
- Go Languages Reviews (Programming)
- Based on Google Cloud Storage Mirroring open Maven Central Repository (Server)
- Linux system performance analysis and top command ps.pstree Comments (Linux)
- Three kinds of binary tree traversal recursive and iterative solution (Programming)
- For the FreeBSD install Adobe Flash plug-in (Linux)
- Linux Systems Getting Started Learning: Configuration PCI passthrough on a virtual machine (Linux)
- Dom4j change XML coding (Programming)
- ethtool implementation framework and application in Linux (Linux)
- Ubuntu 14.04 kernel after the restart boot black screen to solve (Linux)
- C ++ runtime environment built on CentOS 6.6 and Oracle database connection (Database)
- Oracle View Object Information (Database)
- Troubleshooting Linux virtual machine device id and the letter of inconsistencies (Linux)
- Unix average load average load calculation method (Server)
- To use Android RecyclerView (Programming)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.