Android :: Getting View To Redraw When Parameters Change
Sep 20, 2010
I want to get a set of Views to redraw after I change some drawing parameters. I'm calling invalidate() and forceLayout() on the parent of the Views but nothing happens. If I rotate the screen then the Views redraw correctly using the new parameters, as you would expect. What else do I need to do to get the Views to redraw?
View 3 Replies
Aug 14, 2009
I have a custom view, that overrides the onDraw() method. For better performance I want to redraw only a small part of Canvas in onDraw().
View 4 Replies
View Related
Jun 1, 2010
I have a custom view that fills my entire screen. (A piano keyboard) When a user touches the key, it causes invalidate() to be called and the whole keyboard gets redrawn to show the new state with a touched key.
Currently the view is very simple, but I plan to add a bit more nice graphics. Since the whole keyboard is dynamically rendered this would make redrawing the entire keyboard more expensive.
So I thought, let's look into partial redrawing. Now I call invalidate(Rect dirty) with the correct dirty region. I set my onDraw(Canvas canvas) method to only draw the keys in the dirty region if I do indeed want a partial redraw. This results in those keys being drawn, but the rest of the keyboard is totally black/not drawn at all.
Am I wrong in expecting that calling invalidate(Rect dirty) would "cache" the current canvas, and only "allows" drawing in the dirty region?
Is there any way I can achieve what I want? (A way to "cache" the canvas and only redraw the dirty area?"
View 1 Replies
View Related
Feb 3, 2010
We are using TextView's Ellipsize function to scrolling text in it and there many other controls in our window. We noticed CPU would go up to 50% if text started scrolling. After digging deeper, we found all controls in our layout kept drawing when texts scrolling. We wonder why? And how to avoid all controls redrawing?
View 8 Replies
View Related
Jan 5, 2010
I have, for the time being, a custom view with a 9-patch image as a border.
That custom view is placed three times in a LinearLayout, so it looks like this:
+------------------------+
| CustomView |
+------------------------+
| CustomView |
+------------------------+
| CustomView |
+------------------------+
I have attached a click event listener to the View, so it is clickable. But then I click it, I cant see that I am clicking it - there is no change in color.
So, Im thought that I'd attach a "onPress" listener, and then change the background of the view but I couldnt find such a listener.
So, the question is - how do I create the behaviour on the View so I can see that it is being pressed? this is normally done in Android with a green background to indicate that it is now being pressed.
View 1 Replies
View Related
Jul 29, 2009
I have an expandable list view with a static array for the group data and an SQLite database for the child data. It is implemented with the BaseExpandableListAdapter and works great, except, when I edit the database to delete or add children to the list I do not see the changes onscreen. It looks like I can use the registerDataSetObserver method to notify the adapter and expandable list of a data change. What I have to do in the callback to make Android redraw the list after data changes is what I need to know. Can I do it? Documentation on this part of the SDK is a bit sparse and expandable list view example code is not a good match. Can anyone offer advice on how to use a DataSetObserver? It feels like I have to switch over to a Cursor type adapter.
View 2 Replies
View Related
Mar 10, 2010
I've found that after changing the overlays on a MapView, the changes aren't seen until the user moves the Map, causing a redraw. Is there a way to force this redraw?
View 1 Replies
View Related
Sep 29, 2010
I'm implementing a fairly standard app with the Android sdk that involves drawing using the SurfaceView, SurfaceHolder, Callback setup.
In my main thread (UI thread) I have no drawing or handling of the SurfaceHolder (or the canvas you retrieve with it).
In a separate thread I have the following:
CODE:...............
This code is being executed, throws no exceptions, and has no negative side effects that I can find; however, the unlockCanvasAndPost() call never causes onDraw() to be called.
In other words, unlockCanvasAndPost() does not cause a redraw of the SurfaceView.
Any ideas what could cause this symptom? I have plenty of java experience, a fair amount of android experience, and a lot of debugging experience and cannot track this one down.
View 2 Replies
View Related
Nov 22, 2010
I have a linearlayout that is filled with texviews dynamically when i click on a button , but the content of linearlayout doesn't appear, how can i redraw it?
View 2 Replies
View Related
Oct 7, 2010
I have a RadioGroup view inside a LinearLayout. The radio buttons are added from dataList. If I call the code below from inside onCreate, the correct button is checked. However the dataList can get updated from time to time and after that happens I call this code again, without destroying the Activity. After that, the view is redrawn but no button is checked. I suspect the RadioGroup checked-button bookkeeping is getting confused by the removeAllViews call. Any ideas what might be going wrong?
View 6 Replies
View Related
Apr 15, 2010
I have created a custom component in my program by extending a ViewGroup. This component listens to touch events and are supposed to start animations when the user has move their finger past some certain points.I'm able to start animations while the user is touching the screen. But I'm not able to start animations if the user doesn't move their finger. It's probably that the phone thinks it doesn't have to update the screen if the user isn't moving their finger.I added some logs and according to them the animation starts and ends but it doesn't draw on the screen. I have the same problems when starting an animation with a timer.I use AlphaAnimations and Translate Animations on ImageViews. I have tried to use invalidate() both on the component and the ImageView but it doesn't help.Anyone who has an idea how to solve this?
View 1 Replies
View Related
Nov 8, 2009
I am new to Android development, just reading docs and trying the APIs. I am quit confused how ImageView managed to draw just a part of its content after an invalidate(Rect) invocation.
I've checked ImageView.java, found no other drawing method except onDraw(Canvas), but onDraw(Canvas) only cut the drawable only if it is beyound the view's visible boundary. I also read the implementation of View.invalidate(Rect), I think the key of this function is calling to mParent.invalidateChild(this, r);
However, I think the parent view doesn't know how to draw the child in the given Rect, it finally has to call some method of it child to paint out. Has anybody investigated this part of codes? Would you please give me some guide?
View 2 Replies
View Related
Jun 1, 2009
I have a ListView containing a few different type of items, all having their own background image and font color. In my first implementation I implemented each type of item as its own layout with the background image etc defined in XML (and implemented Adapter.getView() so that it only reuses convertView if it's of the correct type). This works fine but the performance is not that great while scrolling since I'm inflating quite a few Views due to convertView mismatches, so instead I tried using the same layout for all items (to benefit fully from convertView reuse) and changing the background image and font size in runtime. I even keep the three background Drawables I need as members to save time decoding them from a resource for each item, and call View.setBackgroundDrawable() from Adapter.getView(). The problem is, sometimes the 9-patch is not correctly wrapped around the content of the list item when using this approach. While scrolling it usually looks correct but when the scrolling stops, or sometimes when I just tap anywhere on the list, the background 9-patch of some large items starts flickering and is either cropped or resized to its original PNG size rather than stretched to wrap the content.
First of all, I suspect this is a bug? Any ideas why this happens? Could it be that the View is not always measured to reflect the changed content when the 9-patch is applied? I have tried adding an extra call to View.invalidate() but it doesn't solve the problem. Second, does this approach sound reasonable at all, or how should I go about to optimize this scenario?
View 4 Replies
View Related
Nov 19, 2010
I've got a TabHost with three tabs; each holding one activity.I'd like to change the view of one tab to another view - how can I do that programatically? I don't like to use ActivityGroups, as I've experienced several problems with ActivityGroups.It would be perfect if I could add a View on top of the current one, so the back button is working, too (or at least I could fetch the back button and remove the topmost view).
View 1 Replies
View Related
Nov 10, 2009
All works fine, however I want the gameboard to appear as square. So I need to resize the board at runtime to put it in the center of the screen and make it square. I tried many options without success.
View 2 Replies
View Related
Dec 10, 2009
I want to provide a clickthrough on the list in a tab which opens another view. I need to open the new view within the same tab. I then need to provide a back button on the changed layout to change the view to original view.I have tried this. I am trying to access the tabSpec from main activity class [MainTabView] and set the intent as follows. Java: MainTabView.tabSpec1.setContent(new Intent(this, AView.class)); MainTabView.mTabHost.setCurrentTab(0); MainTabView.mTabHost.invalidate(); But this does not change the view immediately but changes it when I go to another tab and come to the starting tab. How can I make it to refresh it as soon as the content has been changed to another intent?
View 2 Replies
View Related
Dec 11, 2009
I want to provide a clickthrough on the list in a tab which opens another view.I need to open the new view within the same tab. I then need to provide a back button on the changed layout to change the view to original view.But this does not change the view immediately but changes it when I go to another tab and come to the starting tab. How can I make it to refresh it as soon as the content has been changed to another intent?
View 3 Replies
View Related
Sep 4, 2010
Has anyone else noticed that after updating to Froyo, that text wrapping/redrawing is not working properly while web-browsing?For example, if you go to a text heavy website, like Reddit, and I zoom in (either by double-tap or pinch), the text will redraw, but it will be slightly larger than the screen's width. To read the text, I am required to scroll a bit to the right, then back to the left, and so on.I never had this problem prior to the Froyo update. Can anyone else confirm that they are having this problem? before I get bombed on, I should say that I am very happy with Froyo in other regards. I have not had any battery drain issues or any lag anywhere. I did not do a factory reset.
View 2 Replies
View Related
Aug 4, 2010
I was usind ADW for a while and liked it. I like LP better because of the scrollable bar bit when I hit the home key or back up to home, about 50+% of the time it takes ten seconds to redraw. I do ude widgets but it should not be this bad. In settings I tried keeping LP in memory, I set high mem useage and many of the other options and its the same. I even uninstalled wiped cache pulled battery and its the same. Is there a setting config I should be using, or not?
View 2 Replies
View Related
Jul 28, 2010
Everywhere I look online, it seems that I must use an animation to change views dynamically (like slide in, out). Do I have to do this, or can I simple just setContentView() on each new activity?
View 1 Replies
View Related
May 13, 2009
I'd like to create my ListView and make it's Views be changed while selected (or, clicked). How could I do it?
View 3 Replies
View Related
Apr 26, 2010
I have an element in the page that under certain circumstances has to get the margin-top increased. as the title says, the element is systematically rendered in the page via xml. Only in certain circumstances, and when that specific view is already rendered, I need to increase the margin. Is it possible at all? workaround?
View 5 Replies
View Related
Jun 17, 2009
Is the view aware of the orientation change in order to return updated size after a change in orientation? I'm handling the orientation myself (android:configChanges="orientation|keyboardHidden"). Does it means that I have to take into account the orientation state when querying for view.getHeight()? The view returns the same value as before the orientation change. It this the normal behavior or I should "notify" somehow the view to "refresh" its size.
View 2 Replies
View Related
May 22, 2010
how to change the font in textview? as default its shown up as Arial. how to change it to helvetica?
View 2 Replies
View Related
Sep 13, 2010
I'm trying to make a timeout gauge bar animation effect:The width of a lengthy colorful bitmap image is decreasing, but not x-scaling.so the image looks not changing and the visible area shrinks.I couldn't find the sole ImageView clipping or masking support in android.then changing the shrink_box's width will clip the portion of the still_image.But I failed to change the width of the view smoothly.I tried to change the LayoutParam.width in applyTransformation() but got an Exception, it seems not allowed. How can I make an Animation that changes the width of the view. OR is there a proper method to achieve the above effect?
View 1 Replies
View Related
Sep 16, 2010
i“m working with a lineal layout and I“m trying to change the text of a TextView but it doesn“t refresh. When I debug I“ve checked that the text have changed correctly.public class Position extends Activity {
Button botonempezar;
Button botonsalir;
TextView text;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.position);
botonsalir = (Button) findViewById(R.id.salir);
botonempezar = (Button) findViewById(R.id.Empezar);
text = (TextView) findViewById(R.id.Textoposicion);
botonsalir.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
onDestroy();
finish();
} botonempezar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
searchPosition();
private void searchPosition(){
boolean condition = true;
do{
determinatePosition();
}while(condition == true);
private void determinatePosition(){
this.text.setText("New text");
//this.text.invalidate();
this.text.postInvalidate();
Toast.makeText(getBaseContext(), "New text", Toast.LENGTH_SHORT);// this doesnt work neither.
Here I post the code of the xml file. Its really silly but it could be the problem:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_height="wrap_content"
android:id="@+id/Textoposicion"
android:text="PosiciĆ³n desconocida"
android:layout_width="fill_parent"
android:layout_marginTop="20dip"
android:inputType="text">
</TextView>
<Button android:layout_height="wrap_content"
android:id="@+id/Empezar" android:text="Empezar"
android:layout_width="fill_parent"
android:layout_marginTop="20dip">
</Button>
<Button
android:layout_height="wrap_content"
android:id="@+id/salir"
android:layout_marginTop="20dip"
android:text="Finalizar programa"
android:gravity="center" android:layout_width="fill_parent">
</Button></LinearLayout>
I have edited the post because I omitted part of the code to make it simpler but I think I may suppressed the problem too. It runs in a endless loop, could be this the mistake?
View 3 Replies
View Related
Aug 23, 2009
My Application need to perform a database search when the user change the text in an EditText view. I need a method like onChange to allow me to know when the text in the EditText changed. How can I detect a change in the EditText view?
View 2 Replies
View Related
Jun 23, 2012
I have a simple draw application on Canvas. User should be able to draw with a chosen color. On MotionEvent.ACTION_UP, invalidate() is called. Now it redraws previously drawn lines with the current color ( Redrawing the entire drawing with the current color). I do not want to change the color of previously drawn lines. I am not sure what is missing. Can I make it redraw only newly drawn lines?
View 4 Replies
View Related
Oct 2, 2009
is there a way to have a view use a different layout when an orientation change occurs. suppose i want the view to look one way in portrait and another way in landscape. all the same data, but arranged differently.I'm thinking one way to do this would be to have two different linear layouts with android:visibility="gone" and simply display the appropriate one (set android:visibility="visible") based on orientation -- i.e. do this from code.is there a way to do this in xml? or something like this (i.e. in landscape, put the textview here, in portrait, put it here instead)?
View 2 Replies
View Related
Nov 12, 2010
I was wondering if anyone knew of a way or an app that would allow me to see all my gmail accounts when opening the gmail app.
Basically instead of it opening straight to the last account I had opened I would like for it to default to the page that shows me each of my accounts and their unread counts. You know, the page you get when you hit Menu - Accounts?
View 1 Replies
View Related