I created a code that animates all the children of the ListView except the position 1.
if I reduce the application with the "home" button and I come back on, the animation of the view at position 1 is not launched. So if I press a "Preferences" button in the action bar which launches another activity, and then I press the "back" button, the animation is started.
Also, if I click on the item, the animation is started.
Finally, if I scroll to hide the view at position 1 and I scroll to draw again, the animation is started.
I do not think posting the code is useful because it works for all other views.
I tried to use the "convertView" of the Adapter, I also try to redraw the whole, it does not work.
I hope that the solution lies in an option to enable it in the ListView. Thank you.
I have the same problem. I just noticed that the view at position 1 is redrawn (in the getView method of the adapter) more times than others view.
Your listview layout_width and layout_height attr. are match_parent? If listview layout attrs are wrap_content, it called getView every width or height changing.
Optimize adapter code but your code want position variable shouldn't use. Because very dangerous row cached.
if( convertView == null){
// inflate
...
convertView.setTag(holder);
}else{
holder = ((Holder)convertView.getTag());
}
...
Other options very simply but not fast and memory friendly
// inflate convertView
convertView = inflater.inflate(, );
// than use convertViews child view
Related
Is it possible to navigate inside a sheet view and animate its height to adapt to the new sheet height?
Basically what I am looking for is this effect:
https://i.ibb.co/hWH4gnJ/RPReplay-Final1667845678-MP4.gif
Not sure if this is possible without creating a custom view, and just using the native sheet component from SwiftUI.
I've tried different approaches and I can't get it to work. If I use isPresented, the view reloads and the sheet panel pops up or down to the new height without any animation. If I use item the panel gets dismissed and then reopens again with the new height.
iOS 16 brings the option to use .presentationDetents() method that takes desired sheet height as an argument. Try assigning the method to each of your views and then change the height accordingly.
...
// First view
Text("Detail")
.presentationDetents([.height(250)])
// Second view
Text("More detail")
.presentationDetents([.height(100)])
...
This site does a really good job explaining the whole process. Haven't tried that myself, but I'm pretty sure it'll work.
I have a scroll view which contains different ui components such as text fields, labels etc.
The scroll view takes almost the full size of the screen. Logically separated, I want to add/display a button which is not a part of the content of the scroll view.
This leads to the problem that my button doesn't react on my touches. In case, I reduce the size of the scroll view so that the frames don't interfere with the ones from the button, everything works as expected.
I tried to bring the button to the front (view.bringSubviewToFront(infoButton)) but it still doesn't work.
I think you want to implement something like 'Gmail app, a plus button is floating at the bottom right of the screen.
add your scroll view to view and add other elements to scroll view:
view.addSubview(yourScrollView)
yourScrollView.addSubview(yourButton)
yourScrollView.addSubview(yourLabel)
after you finished adding scrollView's sub views it's time to add your button to -> View (not scroll view)
and everything should work fine as you expected
Issue is solved!
It is a matter of how you ad your sub views to the main view. In my case, I added the info button first to the main view followed by adding the scroll view to the main view.
You need to change the order. First you add the scroll view to the main view and then the button.
I have a view controller that looks like this:
The root view is a scroll view. When the view first loads, it scrolls just fine.
However, I sometimes need to remove one of the buttons at the bottom with code like this:
if (item.url==nil||[item.url isEqualToString:#""]) {
[overdriveButton removeFromSuperview];
}
After doing so, however, the scroll view will no longer scroll. (Those views in the middle of the screen expand, so there's always plenty of content that extends beyond the bottom of the screen).
Note that I am required to use Auto Layout here. My suspicion is that this is part of the problem. Does the removal of the button (and, necessarily, the associated constraints) somehow confuse the scroll view?
Either set UIScrollView's "contentSize" property, or call "sizeToFit" method.
In my application i've a line for increasing the width of a widget(by dragging the line to right/left) and i've the ScrollView enabled in the same activity. I need to disable the scroll view action when the user touches the line and when user releases, it should be enabled. The ScrollView should be in visible state but the action of the scroll view should be disabled. Please help me in solving this problem. I've tried with these but none of them is working.
scroll.setEnabled(false);
scroll.setFocusable(false);
scroll.setHorizontalScrollBarEnabled(false);
scroll.setVerticalScrollBarEnabled(false);
Thanks in advance.
This might be a bit late but I ran into the same problem so my solution is similar to above, had to disable the OnTouchListener as follows:
// Get the ScrollView
final ScrollView myScroll = (ScrollView) findViewById(R.id.display_scrollview);
// Disable Scrolling by setting up an OnTouchListener to do nothing
myScroll.setOnTouchListener( new OnTouchListener(){
#Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
// Enable Scrolling by removing the OnTouchListner
tvDisplayScroll.setOnTouchListener(null);
This is a bit late, but an even easier way is to just get your parent ViewGroup and call requestDisallowInterceptTouchEvent(true) on it. This causes not only the immediate parent (scroll view) but any other parent objects that might intercept the touch to ignore it for the duration of the particular event. This is great when you have a draggable child AND draggable parent, and want to disable parent dragging while the child is being dragged.
It's also a more general solution than specifically disabling the scroll view. If you re-use your draggable child view somewhere else, it will still work: You don't need to know the scroll view's ID. Code that's re-usable without modification is always good.
If anyone's using Android L or later and overriding onTouch and onInterceptTouchEvent isn't working:
try overriding onStartNestedScroll and return false.
There is also a new XML attribute nestedScrollingEnabled, but it seems like it has to be on the View that is leaking the scroll event, rather than on the ScrollView being affected by the leak, or anywhere in the layout hierarchy between them. So if you don't know in advance what child ScrollViews you might have, overriding onStartNestedScroll for the affected ScrollView is the way to go.
How can I implement tweetie like swipe menu?
I'm done with developing a tableviewcontroller with a customcell. The customcell implements touchesbegan and touchesMoved. It also reports swipe gestures via a selector to the parent tableviewcontroller.
Now how should I go about hiding the "Swiped" cell and replacing it with a "swipe menu view" and how should I get the actions from the buttons present on the swipeview?
Each table view cell has a contentView that encompasses the whole area of the cell. Add your swipe-menu view as a single container view with an opaque background to the contentview so it's on top of everything else. Position it so it's flush left (x=0), set the width to 0, and set it as hidden. That single container can include any other subview (buttons, etc) and you can set the cell view itself as the target of the button events (then bubble it up to the parent table view along with cell index information).
When time comes to show it, set it to not hidden then use UIView animation to make the container width go from 0 to full table width. Set the duration pretty low (i.e. 0.2 seconds) so it's zippy. When you run the animation, the swipe-menu shows up over everything else in the cell content view. To make it disappear just reverse it (set the width to 0 in a UIView BeginAnimation block). You may also want to set an animation completion handler at the end and do some housekeeping there (set the container view to hidden, release memory, etc).
I've done a tweetie like menu, there's no full code but i blogged about it. Hope it helps!
http://petersteinberger.com/2010/01/tweetie-like-swipe-menu-for-iphone-apps/