android


Moving of Screen


I want to have a layout (kind doesn't matter) that ia acctual size will be bigger from the real size of the screen multiplies by 5. I have created a surfesview which takes the canvas and draws what I want, but how can I move the screen by touch so I will be able to see every part of the screen? How can I be able to know what view haas been clicked (I want something will happen onClick)?
It seems to me that you would want to use a OnTouchListener or the View.onTouchEvent(MotionEvent ev) to detect touches and act appropriately:
For example:
myView.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_UP:
// Perform click operation
return true;
case MotionEvent.ACTION_MOVE:
// Move to another area based on the event
return true;
}
return false;
}
});
Or inside your class:
int downX = -1;
int downY = -1;
public boolean onTouchEvent(MotionEvent event) {
int eventAction = event.getAction();
// You may need the x/y location
int x = (int)event.getX();
int y = (int)event.getY();
// put your code in here to handle the event
switch (eventAction) {
case MotionEvent.ACTION_DOWN:
downX = x;
downY = y;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
downX = -1;
downY = -1;
// decide what to do here about movement
break;
case MotionEvent.ACTION_MOVE:
int deltaX = x - downX;
int deltaY = y - downY;
// This is one way of doing it, it might not be exactly what you want, but you can start from her
setTranslationX(getTranslationX() + deltaX);
setTranslationY(getTranslationY() + deltaY);
break;
}
return true;
}

Related Links

How Can I Include Only Certain Source Files In Gradle
Android Virtual Device won't load
Android socket streaming
Multiple intent to broadcast
Attempt to invoke virtual method 'boolean java.util.ArrayList.isEmpty()' on a null object reference
Can I add autocomplete feature to my alert input dialog?
Java RSS Feed Reader Android Studio
Android Lollipop Set Status Bar Text Color
Location updates using google fused API client don't work
isReachable not working in android studio
CardView Click state not working [closed]
Performance Testing for Native Mobile Applications
Overriding string resources from module/library that have translations in Android
Android: how to change menu item at page scrolling with ViewPager?
transfer udp packets in android
Android SqliteAssetHelper copy user saved data

Categories

HOME
service-worker
hyperlink
jax-rs
flex
interface
themes
serialization
newrelic
yandex
cublas
tivoli
3d-reconstruction
settings
character
rcloud
32bit-64bit
little-proxy
mod-security
mautic
stellar.js
code-generation
3nf
glyphicons
google-container-registry
soci
cfml
undertow
exit
xcode-ui-testing
surveymonkey
jquery-multiselect
bulletphysics
angularjs-components
tpm
nsurl
constexpr
corenlp-server
sql-server-2000
turfjs
gojs
classcastexception
dynamic-jasper
engine.io
sharepoint-workflow
swagger-php
git-rewrite-history
connection-pool
projects-and-solutions
setup.py
memory-mapping
servermanager
fwrite
serde
twilio-click-to-call
arq
headless
excel-dna
skin
jqchart
rackspace-cloud
structuremap4
async.js
iotivity
file-uri
windows-azure-queues
tooleap
cassia
bizagi
cda
createprocess
false-sharing
blitline
phpgrid
directdraw
dynatree
ocra
avahi
keyup
cosine-similarity
execve
mruby
sql-scripts
paw
imagefilter
trdion2011
grails-domain-class
xml-dsig
spring-remoting
git-repo
multitasking
scriptaculous
gtm-oauth2
script#
windows-98
http-status-code-410
nokia-s40
ilasm
jsr286
infobright
screen-size
codebase
mtu
nhprof
cac
aspmenu
sifr
echo3
purepdf
tui
dsoframer
pbcopy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App