Android :: Move A View Object In Circle?
Aug 7, 2009
I have a very simple requirement. I have a View object, lets say an ImageView object. I want to move this ImageView object in a circle.
More specifically, I want to move it along an arc, which is not a complete circle. I found in Android Documentation that comes with SDK that we can create a path from an arc but it does not mention how to use this path to make an animation that goes along that path.
Please note that I dont want to rotate the image. I have to move it in a circular path.
View 3 Replies
Feb 28, 2010
I like to know how can i clone a view object which is already there in the view hierarchy, so that it can be added to the same view hierarchy again.
View 1 Replies
View Related
Jul 5, 2009
i'm doing some experiments with OpenGL using the GLSurfaceView introduced in 1.5 In my Renderer I keep track of the time spent to render the last frame and pass this value to the method that update my model. The goal is to keep objects movements on the screen independent from the rendering time. Now this seems to work perfectly in the emulator, but on the real device is at least 4/5 times slower! Has anyone experienced the same problem? Or, anyone has a clue of what I'm doing wrong? Here's pieces of the code I'm using
View 3 Replies
View Related
Sep 3, 2010
First post: This is probably a dumb question. Why do I get a white screen with a circle and a gray triangle when trying to view flash content? Example: Zinio or Olivesoftware. Motodroid, Android 2.2, Flash 10.1.92.8 from Market.
View 1 Replies
View Related
Oct 10, 2010
This is a followup to this post: http://stackoverflow.com/questions/3897176/findviewbyid-in-a-subclassed-surfaceview-throwing-runtimeexception Based on Romain Guy's feedback (which I'll accept shortly as it is a solution), I'd like to obtain the calling Activity from within the View, so that I can use it to obtain the desired Text View resource. I don't see any methods in View that return Activity. What is the proper way to do this? Or is there a better alternative for working with TextViews from within another View context. Basically, I am calling setContentView(R.layout.xxx) in onCreate() (as usual), so I don't really have a way to pass in references to additional TextViews unless I awkwardly retrieve the View after setContentView and then make calls on it.
View 1 Replies
View Related
May 7, 2009
We see API for saying which is the next focusable view.. however during the event handling we want to set the focus to xyz view object pro grammatically . Is that possible.
View 3 Replies
View Related
Mar 9, 2009
In the Tab2 of TabActivity in the APIDemo example, it has this method to create a View object for each tab. code...
Can you please tell me how can I create a View for each tab from an xml layout file? For example code...
View 2 Replies
View Related
Jan 11, 2010
I have a Adapter View derived class (say GridLayout) in which I arrange views in a grid. When items in the grid exceed the height of the GridLayout( or screen) I want a scrollbar to appear. I have handled scrolling in onTouchEvent. But the problem is the scrollbars don't appear. I have set the vertical scrollbar to be enabled, but no use. The docs say the scrollbar appears every time the scrollTo or scrollBy methods are called.
View 2 Replies
View Related
Sep 15, 2010
I want to share streams of a socket connection between the activities of a tab view. In particular the tab activity creates the socket and gets the i/o streams,so i want that tabbed activities use these streams to retrieve informations without reconnect to the server each time i switch from a tab to another. I know i can use the application class to have a global state, but i don't know how.
View 4 Replies
View Related
Aug 3, 2010
I think this is a pretty simple question but I'm having trouble finding the answer out there.I'm developing an android application (currently developing against v1.5 API) and one of the activities use a ListView. I want to be able to set the properties of each List Item based on the state of an in memory object rather than the state of the view or list item.Here is a simple example....say I have a Person class who's public members are defined as follows. Code...
View 1 Replies
View Related
Dec 14, 2009
This subject originates here: http://groups.google.com/group/android-beginners/browse_thread/thread...
To sum up:
When I click on an item in the ListView, the background color that gets changed is not that of the clicked item but instead of the other item in the opposite side relative to the middle item:
1 <-- I click here 2 3 <-- Acts as a mirror 4 5 <-- This is the one that gets changed
1 2 <-- This is the one that gets changed 3 <-- Acts as a mirror 4 <-- I click here 5
This problem persists even when I use CheckedTextView like what is suggested in the post.
I use the latest stable SDK.
This problem occurs when the target platform is Android 1.6, 2.0 or 2.0.1.
The problem does not occur when the target platform is Android 1.1 or 1.5.
However, the problem will also occur when the program is compiled for 1.5 and run in 2.0.1.
The simple problematic code can be found here: [url]
There I also put the screenshots showing the problem: demo01.png: I click an item. demo02.png: the clicked item doesn't get changed but the reflective item does.
Is this a bug in newer Android platforms?
If it is intended, what is the reason and could you please show me how I should fix my code?
View 6 Replies
View Related
Nov 18, 2010
I want to get the current focus view in my Service to check the view is a EditText and append some texts in it (for all EditTexts, not only in my application).
I found some methods to do this, like Activity.getCurrentFocus() and Windows.getCurrentFocus(). But these methods are used in a Activity.
How can I use these methods in a Service? Or is there another way to do?
View 2 Replies
View Related
Nov 7, 2010
I have a custom view that draws to a canvas. I am trying to invoke changes to the canvas when the user pushes a button from the activity that this view is tied to. Currently, I am attempting to do this by calling a public method, called setNewDrawable, that I created inside the view.
The debugger is giving me different values for the view ID depending on whether I'm inside setNewDrawable or inside the Overridden onDraw method when I post an Invalidate.
For example the debugger variables show: (This - MyView id=830067720176) or (This - MyView id=830067712344) in setNewDrawable and onDraw respectively. This makes me think I basically have two copies of the object and I am essentially interacting with the wrong one.
How can I get information to my custom View in order to determine what it draws?
Here is the code I am running...
View 1 Replies
View Related
Mar 3, 2009
My purpose is very simple : each 1second, I want to redraw an object on different place on background. I do not know where my error on this code below. Here is my code:
public class My_View extends View{ private Bitmap mBackground_img;
private Drawable mMoveObject; private int mObjectw,mObjecth; private int Dx,Dy;
private Handler myHandler = new Handler(); private long lasttime;
public My_View(Context context,AttributeSet ats,int ds) {
super(context,ats,ds); init(context);
} public My_View(Context context,AttributeSet ats) { super(context,ats);
init(context); } public My_View(Context context) { super(context);
init(context); } public void change() { invalidate();
} private void init(Context context) {
Resources res = context.getResources();
mMoveObject = res.getDrawable (R.drawable.lander_firing);
mBackground_img = BitmapFactory.decodeResource(res, R.drawable.my_pic);
mObjectw = mMoveObject.getIntrinsicWidth();
mObjecth = mMoveObject.getIntrinsicHeight();
Dx = Dy = 0; lasttime = System.currentTimeMillis() + 1000;
Thread mthread = new Thread(null,doBackground,"Background");
mthread.start(); } private Runnable doBackground = new Runnable() {
public void run() { long now = System.currentTimeMillis();
if(lasttime < now ) { Dx = Dx + 10; Dy = Dy + 10;
lasttime = now + 1000; myHandler.post(change_view);
} } }; private Runnable change_view = new Runnable() {
public void run() { change();
} };
@Override public void onDraw(Canvas canvas) {
canvas.drawBitmap(mBackground_img,0 ,0 , null);
mMoveObject.setBounds(Dx, Dy, Dx+mObjectw, Dy+mObjecth);
mMoveObject.draw(canvas);
} }
View 7 Replies
View Related
Nov 11, 2010
My question is almost exactly this question:
Clone textview to append it to a ViewGroup
However, I was inflating a view, and then attempting to clone it at the object level for performance reasons (I don't want to parse XML every single time), so that answer doesn't help me. View.clone() is protected and it apparently doesn't have a copy constructor. Is there any way to do this?
View 1 Replies
View Related
Nov 7, 2010
In my program I have a custom view object. Inside the view class is a method called foo. For some reason when I call foo from my activity, it doesn't fire. Here is the code:
XML of the custom view:
<com.company.application.MyView android:id="@+id/my_view" android:layout_width="wrap_content" android:layout_height="wrap_content" />
The activity code:
public class Main extends Activity { MyView mView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = li.inflate(R.layout.main, null); mView= (MyView) v.findViewById(R.id.my_view);
//A button to fire the method inside foo() Button switchLeft = (Button) findViewById(R.id.switch_left); switchLeft.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { callTest(); } } );
} public void callTest() { Log.w(this.getClass().getName(), "clicked left arrow");
mView.foo(); mView.postInvalidate();
} }
Finally here is foo:
public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas); Log.w(this.getClass().getName(), "background set");
}
The first log is always written when the button is pressed, but the second log is not because foo never fires. What is the deal here? Upon request, the full view
public class MyView extends View { Drawable mBackground; Context mContext;
public MyView (Context context) { super(context); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public MyView (Context context, AttributeSet attrs) {
super(context, attrs); mContext = context;
mBackground = mContext.getResources().getDrawable(R.drawable.leftarrow1);
} public void foo() { mBackground = mContext.getResources().getDrawable(R.drawable.temp_canvas);
Log.w(this.getClass().getName(), "background set"); }
@Override public void onDraw(Canvas canvas) { Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL); // draw a solid blue circle
paint.setColor(Color.BLUE); canvas.drawCircle(20, 20, 15, paint);
// draw a test background mBackground.setBounds(0, 0, 300, 400);
mBackground.draw(canvas); }
}
View 1 Replies
View Related
Jul 4, 2010
I would like to switch to certain views in a ViewFlipper. Currently, I have 6 children inside the ViewFlipper. And I am having some buttons for navigation. It is very much similar to "News and weather" application.
View 1 Replies
View Related
Sep 15, 2010
So I have an ImageView sitting on a FrameLayout.I want to move this image view when user taps on it and drags it somewhere.This does not work however.The imageView does not move. Do I need to refresh the view somehow after I set new layout parameters?
View 1 Replies
View Related
Sep 9, 2009
I want to do some automated testcase with Instrumentation . Suggest that my AUT has 2 Activity. After clicking the button in ther first Activity, the second one will be shown with new content base on what we enter in the first Activity.) Instrumentation provides us the function called startActivitySync() and return the Activity object for processing. My question is how we can get the pointer of the second Activity after the it is shown by clicking the button on the first activity.?
View 2 Replies
View Related
Jun 8, 2009
I would like to convert a Picture object to Bitmap object in memory, without writing data to disk.
View 2 Replies
View Related
Sep 21, 2009
I have an Activity that running on system. I can get the Intent that is used to start the activity. But i don't know how to get the Activity object from the Intent object or something else. Can anyone tell me how to do this??? Note that, I don't use Instrumentation object.
View 11 Replies
View Related
Feb 18, 2009
I am trying to get a FileInputStream object on an image that the user selects from the picture gallery.
This is the android URI returned by android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI content://media/external/images/media/3
When I try to construct a java URI object from this object, I get an IllegalArgumentException with the exception description Expected file scheme in URI: content://media/external/images/media/3 whereas the android URI shows the scheme as content
Never found a solution for the original question. But if you want the byte stream of an image in the pictures gallery, this piece of code will do that.
CODE:...................
View 4 Replies
View Related
Apr 26, 2010
I have some fave. apps I would like to move to the first loading page.
View 3 Replies
View Related
Sep 2, 2009
I'm new to openGL and I have done some first tests with drawing a triangle. Now I would like to draw a circle, which is filled with a texture, but I have no idea, how to do so.Can someone of you give me a hint?
View 5 Replies
View Related
Sep 2, 2010
I have a question that I wanted to put button and circle on the same canvas. How can I do this? Please give reply as soon as possible.
View 2 Replies
View Related
Oct 29, 2010
Trying to draw a circle at a longitude/latitude position. The circle below doesn't show up, does anybody know why?
View 5 Replies
View Related
Mar 16, 2010
I have to recommend just getting a book on the subject.I learned most everything off of examples and documents on the web.After several months, I finally picked up the blue book and everything I had scoured to find is clearly demonstrated in it.Look for the red book and the blue "superbible."They cover everything you need.There are also books specific to ES.Make sure to get a good 1.1 one and not a 2.0-only one.
View 7 Replies
View Related
Mar 5, 2010
I'd like to display a given String in a circle (so bend the string so that the end of the string touches the beginning of the string). And Then I'd like to let the user rotate the circle by grabbing and dragging it clockwise or counterclockwise. Do you guys know what would be the best (simplest, smoothest) way to do this? I already saw that using drawOnPath i can draw text in a circle. Do you have any tips on how to proceed with dragging and rotating the textcircle?
View 8 Replies
View Related
Nov 2, 2010
When I have a status bar notification with a number inside, it shows the number fine. But later if I show another notification to replace this one, with no number, it shows an empty red circle. This circle shouldn't be there. How do I remove the red circle? See image here: http://jump.fm/UYHGV.
View 1 Replies
View Related
Jan 12, 2010
I've created a bitmap that I'm overlaying over another bitmap. I'd like to alter the transparency of sections of the overlaid bitmap, revealing the bitmap beneath. I can't find a way to write only to the alpha channel of the overlaid bitmap.
For example, I have a bitmap filled with red pixels, and an alpha that is 255, opaque. A solid red bitmap. How do I draw a circle on this map that would lower the alpha values toward 0, transparent?
View 2 Replies
View Related