Search Results

Search found 324 results on 13 pages for 'scrollview'.

Page 2/13 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • iPhone scrollView won't scroll after keyboard is closed

    - by Rob
    I was trying to implement a way to have the UITextField move up when the keyboard opened so that the user could see what they were typing but after implementing the code - it locks my scroll. The view will scroll when the user first gets to that view but after inputting text and closing the keyboard it locks the view. I suspect that it is a problem somewhere in this code: - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSLog(@"Registering for keyboard events"); // Register for the events [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardDidShow:) name: UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardDidHide:) name: UIKeyboardDidHideNotification object:nil]; // Setup content size scrollView.contentSize = CGSizeMake(SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT); //Initially the keyboard is hidden keyboardVisible = NO; } -(void) viewWillDisappear:(BOOL)animated { NSLog (@"Unregister for keyboard events"); [[NSNotificationCenter defaultCenter] removeObserver:self]; } //**-------------------------------** - (void) keyboardDidShow: (NSNotification *)notif { NSLog(@"Keyboard is visible"); // If keyboard is visible, return if (keyboardVisible) { NSLog(@"Keyboard is already visible. Ignore notification."); return; } // Get the size of the keyboard. NSDictionary* info = [notif userInfo]; NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey]; CGSize keyboardSize = [aValue CGRectValue].size; // Save the current location so we can restore // when keyboard is dismissed offset = scrollView.contentOffset; // Resize the scroll view to make room for the keyboard CGRect viewFrame = scrollView.frame; viewFrame.size.height -= keyboardSize.height; scrollView.frame = viewFrame; CGRect textFieldRect = [activeField frame]; textFieldRect.origin.y += 10; [scrollView scrollRectToVisible:textFieldRect animated:YES]; NSLog(@"ao fim"); // Keyboard is now visible keyboardVisible = YES; } -(void) keyboardDidHide: (NSNotification *)notif { // Is the keyboard already shown if (!keyboardVisible) { NSLog(@"Keyboard is already hidden. Ignore notification."); return; } // Reset the frame scroll view to its original value scrollView.frame = CGRectMake(0, 0, SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT); // Reset the scrollview to previous location scrollView.contentOffset = offset; // Keyboard is no longer visible keyboardVisible = NO; } -(BOOL) textFieldShouldBeginEditing:(UITextField*)textField { activeField = textField; return YES; } I defined the size above the #imports as: #define SCROLLVIEW_CONTENT_HEIGHT 1000 #define SCROLLVIEW_CONTENT_WIDTH 320 Really not sure what the issue is.

    Read the article

  • How to change ScrollView's position after touch?

    - by Matt
    I'm trying to make a ScrollView with a list of numbers in it that the user can select from. After the user touches and scrolls, after the finger is lifted I want the scroll to "snap" to the item in the middle of the ScrollView and give me the output. My ScrollView contains a vertical linear layout with TextView objects in it. The ScrollView's vertical size is about 60sp. I think this would involve the ScrollView.onTouch with a ACTION_UP, but I don't know how to use it. Also, is there a way to get an item's index or value based on a position in the list? Thanks!

    Read the article

  • Layout problem: scrollview inside a table, inside a custom dialog

    - by Sean
    I have a layout problem which I can't fix. I've looked through many posts on here, and mine seems to be unique enough to post a question. I've created a custom Dialog which programmatically creates a 3 row table. The top and bottom rows have text, while the middle row contains a ScrollView, which contains a LinearLayout. That LinearLayout then contains some number of views (TextView in this example). Since I'm doing this programmatically, see the XML pseudocode below, and the actual code below that. What I would like to happen, is that when the height of the contained content in the LinearLayout gets too big, the ScrollView does its job, and the header and footer TextView's are always visible. The problem is that when the dialog gets big enough, the ScrollView appears to take over the whole dialog, and my footer TextView disappears off the screen. What can I do to make sure the footer TextView never disappears, but the ScrollView can still function? See the following image links: Footer visible on the left, gone on the right: http://img690.imageshack.us/i/screenshotss.png/ <TableLayout> <TableRow> <TextView> </TableRow> <TableRow> <ScrollView> <LinearLayout> <TextView/> <TextView/> <TextView/> ... </LinearLayout> </ScrollView> </TableRow> <TableRow> <TextView> </TableRow> </TableLayout> Here's the code: public class DialogScrollTest extends Dialog { public DialogScrollTest(Context ctx){ super(ctx); setTitle(""); requestWindowFeature(Window.FEATURE_NO_TITLE); TableLayout table = new TableLayout(ctx); TableRow row; TextView text; row = new TableRow(ctx); { text = new TextView(ctx); text.setText("TestTop"); row.addView(text); } table.addView(row); row = new TableRow(ctx); { ScrollView scroll = new ScrollView(ctx); { LinearLayout linear = new LinearLayout(ctx); linear.setOrientation(LinearLayout.VERTICAL); for(int t=0; t<32; ++t){ text = new TextView(ctx); text.setText("TestScroll"); linear.addView(text); } scroll.addView(linear); } row.addView(scroll); } table.addView(row); row = new TableRow(ctx); { text = new TextView(ctx); text.setText("TestBottom"); row.addView(text); } table.addView(row); this.setContentView(table); } }

    Read the article

  • How to get NEW width/height of root layout in onConfigurationChanged?

    - by jboxer
    One of our views has a ScrollView as its root layout. When the device is rotated and onConfigurationChanged() is called, we'd like to be able to get the ScrollView's new width/height. Our code looks like this: @Override public void onConfigurationChanged(Configuration newConfig) { Log.d(TAG, "Width: '" + findViewById(R.id.scrollview).getWidth() + "'"); Log.d(TAG, "Height: '" + findViewById(R.id.scrollview).getHeight() + "'"); super.onConfigurationChanged(newConfig); Log.d(TAG, "Width: '" + findViewById(R.id.scrollview).getWidth() + "'"); Log.d(TAG, "Height: '" + findViewById(R.id.scrollview).getHeight() + "'"); } And the relevant section of our AndroidManifest.xml looks like this: <activity android:name=".SomeActivity" android:configChanges="keyboardHidden|orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> On our Droid, we expected to see the ScrollView's width go to 854 when switched into landscape, and to 480 when switched back to portrait (and the height do the equivalent switch, minus the menu bar). However, we're seeing the opposite. Here's our LogCat: // Switching to landscape: 03-26 11:26:16.490: DEBUG/ourtag(17245): Width: '480' // Before super 03-26 11:26:16.490: DEBUG/ourtag(17245): Height: '778' // Before super 03-26 11:26:16.529: DEBUG/ourtag(17245): Width: '480' // After super 03-26 11:26:16.536: DEBUG/ourtag(17245): Height: '778' // After super // Switching to portrait: 03-26 11:26:28.724: DEBUG/ourtag(17245): Width: '854' // Before super 03-26 11:26:28.740: DEBUG/ourtag(17245): Height: '404' // Before super 03-26 11:26:28.740: DEBUG/ourtag(17245): Width: '854' // After super 03-26 11:26:28.740: DEBUG/ourtag(17245): Height: '404' // After super Clearly, we're getting the portrait dimensions when we switch to landscape, and the landscape dimensions when we switch to portrait. Is there something we're doing wrong? We could get hacky and solve this, but I feel like there's a simple solution that we're missing.

    Read the article

  • How i zoom perticular part of UIScrollView?

    - by Rajendra Bhole
    HI, I develop an application in which i want to implement the splash screen, on that splash screen i want to bind the scrollView and UIImage. My code as follow, -(void)splashAnimation{ window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; //scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; scrollView = [[UIScrollView alloc] initWithFrame:[window bounds]]; scrollView.pagingEnabled = NO; scrollView.bounces = NO; UIImage *image = [UIImage imageNamed:@"splash.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.userInteractionEnabled = NO; [scrollView addSubview:imageView]; [scrollView setDelegate:self]; //[scrollView release]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { [self splashAnimation]; [self initControllers]; [window addSubview:[mainTabBarController view]]; [window makeKeyAndVisible]; } On my given code the one blank window comes up and stay on. I want to on that blank screen bind my splash.png. *The Above problem is solved* My current code is scrollView.pagingEnabled = NO; scrollView.bounces = NO; UIImage *image = [UIImage imageNamed:@"splash.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.userInteractionEnabled = NO; [scrollView addSubview:imageView]; scrollView.maximumZoomScale = 4.0f; scrollView.minimumZoomScale = 1.0f; CGRect rect = CGRectMake(119, 42, 208, 166); [scrollView zoomToRect:rect animated:YES]; [scrollView setDelegate:self]; [window addSubview:scrollView]; [window makeKeyAndVisible]; i want to zoom the particular part of scrollView.

    Read the article

  • LinearLayout not expanding inside a ScrollView

    - by Felix
    I have a LinearLayout inside a ScrollView that has android:layout_height="fill_parent", but it doesn't expand to the full height of the ScrollView. My layout looks something like: level layout layout_width layout_height 1 LinearLayout fill_parent fill_parent 2 LinearLayout fill_parent wrap_content 3 (some irrelevant stuff) 2 ScrollView fill_parent fill_parent <-- this expands full height 3 LinearLayout fill_parent fill_parent <-- this does not (has orientation=vertical) (following stuff probably are irrelevant, but just to be sure:) 4 TextView fill_parent fill_parent 4 LinearLayout fill_parent wrap_content I can see that the LinearLayout doesn't expand the full height of the ScrollView because in Eclipse in Android Layout Editor, if I select the ScrollView (in the Outline panel) it is highlighted with a red border that fills the screen to the bottom but when I select the LinearLayout its highlight doesn't expand to the bottom of the screen. How can I get it to do so? The effect I'm trying to achieve is to have some text and a button below it (inside the LinearLayout in level 4 there's just a button). The text can be big enough to need a scrollbar, in which case I want the user to have to scroll down in order to see the button. In case the text is not big enough for a scroll bar, I want the LinearLayout containing the button to stick to the bottom of the screen.

    Read the article

  • ScrollView containing TextView does not scroll

    - by Dave Allison
    I have a textview displaying many individual words, each word is a link using Spans and setMovementMethod(LinkMovementMethod.getInstance()); The textview is wrapped by a ScrollView. However the ScrollView does not work as the links in the TextView are activated instead. Is there a way to combine a ScrollView and TextView so that both the scrolling and links in the text work?

    Read the article

  • Manage the scrolling of just one element in a ScrollView

    - by morgan1189
    So, I have a ScrollView which has cards on it. ScrollView must be paging enabled. The goal is that the user must be able to scroll it, even if it has only one card. Since i am having the frame of ScrollView of exactly the same width and height as a picture of a card, i decided to increase the width of a ScrollView.contentSize and add one point to it. It turns out to be working fine, but it glitches a bit - when i drag the card to the left, and then grab it again it moves to right a little bit (i guess, for the value of that one point). If i increase the contentSize, the shift increases too (for example, if the content size is increased by ten, the shift value is ten points too). It really irritates me a lot and I want to get rid of it. Any advice on how to do that? Help is much appreciated. UPD: I tried to manually re-center the card in the scrollViewDidEndDecelerating but that didn't help. My guess for now is that the problem can be solved by setting the content offset to the right value (because now it's (0,0)), but I can't figure out how to do it.

    Read the article

  • Calculate the contentsize of scrollview

    - by neha
    Hi all, I'm having a scrollview as the detailedview of tableview cell. There are multiple views on the detailedview like labels, buttons etc. which I'm creating through interface builder. What I'm creating through interface builder is static. I'm putting everything on a view of height 480. A label on my detailedview is having dynamic text which can extend to any length. The problem is that I need to set the scrollview's content size for which I need its height. How shall I set scrollview's height provided the content is dynamic?

    Read the article

  • How can I place a SurfaceView inside one or more scrollviews ?

    - by Mervin
    Hello, I'm making a 2D game for Android and I've encountered the following problem: - I have made a class that extends SurfaceView and draws my graphics (the size of the canvas that I use has to be 1664x864). This is ofcourse too big for the screen so I needed scrolling, I chose to use google's ScrollView and HorizontalScrollView (nested) for this, But whenever I add my SurfaceView to a ScrollView (whether it's 1 or 2) via AddChild it only draws the ScrollView , SurfaceCreated() isn't even called on the SurfaceView. (Drawing the SurfaceView in a layout without adding it to a ScrollView does work.) I realize that there are other options for scrolling like a screen-sized canvas and bitmap offsets but this would really be my preferred way to go. I would really appreciate some help to make this work.

    Read the article

  • Android : create RelativeLayout in Onclick Button?(Get Crash)

    - by A.A
    I have an Xml that add LinearLayout and RelativeLayout in ScrollView by programmatically.When i add Text with OnclickButton for first time show me message but for 2nd time get me crash : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ScrollView android:id="@+id/scrollID" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" > </ScrollView> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="true" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingLeft="5dp" android:paddingRight="5dp" android:weightSum="1" > <EditText android:id="@+id/txtInpuConversation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.5" android:hint="Text" > <requestFocus /> </EditText> <Button android:id="@+id/btnSend" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="0.5" android:text="Click" /> </LinearLayout> </LinearLayout> My code : public class MainActivity extends Activity { String Medtconversation; EditText edtconversation; TextView txtviewUser; LinearLayout rilative; RelativeLayout relativeLayout; LinearLayout firstLinearLayout; ScrollView sclView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); edtconversation = (EditText) findViewById(R.id.txtInpuConversation); sclView = (ScrollView) findViewById(R.id.scrollID); Button btn = (Button) findViewById(R.id.btnSend); final Context context = this; btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Medtconversation = edtconversation.getText().toString(); txtviewUser = new TextView(MainActivity.this); txtviewUser.setText(Medtconversation); relativeLayout = new RelativeLayout(context); firstLinearLayout= new LinearLayout(context); LayoutParams LLParamsT = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); relativeLayout.setLayoutParams(LLParamsT); relativeLayout.addView(txtviewUser, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); firstLinearLayout.setOrientation(LinearLayout.VERTICAL); LayoutParams LLParams = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); firstLinearLayout.setLayoutParams(LLParams); firstLinearLayout.addView(relativeLayout); Crash here now======>sclView.addView(firstLinearLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); edtconversation.setText(""); } }); } } I need that when i click on Button and send message for 2nd time create a new RelativeLayout in LinearLayout for show.(In scrollView) Error : AndroidRuntime MainActivity$1.onClick(MainActivity.java:54)

    Read the article

  • Remove UIViewController from UIScrollView?

    - by tobi
    Hi, i add different View with (setPageID) to a ScrollView, but know i get a Memory problem on rotaion and i want to remove the actualy not showed view... how can i do this or how can i remove the memory problem? Thanks!!! - (void)setPageID:(int)page { if (page < 0) return; if (page >= self.listOfItems.count) return; CGFloat cx = 0; ScrollingViewStep *controller = [viewControllers objectAtIndex:page]; if ((NSNull *)controller == [NSNull null]) { controller = [[ScrollingViewStep alloc] init]; [viewControllers replaceObjectAtIndex:page withObject:controller]; [controller release]; } if (nil == controller.view.superview) { if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) { cx = 768.0 * page; controller.view.frame = CGRectMake(cx, 0.0 , 768.0f, 926.0f); } else { cx = 1024.0 * page; controller.view.frame = CGRectMake(cx, 0.0 , 1024.0f, 670.0f); } [controller setView:ItemID PageID:page Text:[[self.listOfItems objectAtIndex:page] objectForKey:@"step"]]; [scrollView addSubview:controller.view]; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { CGFloat cx2 = 0; for (int i = 0; i < [self.viewControllers count]; i++) { ScrollingViewStep *viewController = [self.viewControllers objectAtIndex:i]; if ((NSNull *)viewController != [NSNull null]) { if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) { cx2 = 768.0 * i; viewController.view.frame = CGRectMake(cx2, 0.0 , 768.0f, 926.0f); [viewController repos]; } else { cx2 = 1024.0 * i; viewController.view.frame = CGRectMake(cx2, 0.0 , 1024.0f, 670.0f); [viewController repos]; } } } if((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) { CGRect frame = scrollView.frame; frame.origin.x = 768 * currentPageInScrollview; frame.origin.y = 0; [scrollView scrollRectToVisible:frame animated:NO]; } else { CGRect frame = scrollView.frame; frame.origin.x = 1024 * currentPageInScrollview; [scrollView scrollRectToVisible:frame animated:NO]; } pageControlIsChangingPage = YES; return YES; } - (void)didReceiveMemoryWarning { int currentPage = currentPageInScrollview; NSLog(@"MEMORY"); // unload the views+controllers which are no longer visible UIViewController *l; for (int i = 0; i < [self.viewControllers count]; i++) { ScrollingViewStep* viewController = [self.viewControllers objectAtIndex:i]; if((NSNull *)viewController != [NSNull null]) { if(i < currentPage-1 || i > currentPage+1) { [self.viewControllers replaceObjectAtIndex:i withObject:[NSNull null]]; } } } [super didReceiveMemoryWarning]; }

    Read the article

  • Scrolling two views together

    - by user315441
    I currently have one Scrollview which contains a table layout and one list in my activity. Now my problem is that I wanted to move both of them(Scrollview and list) together and with proper synchronization... So if scrollview is being scrolled then listview should also scroll with the same distance, and vice versa... Thanks in advance.. Abhishek

    Read the article

  • Can't touch UITextField on UIScrollView

    - by Chris B
    Hey guys, I know this has been talked about a lot. I think I've gone thru every question on this site, and still have not been able to get this working. I'm new to developing but I have a good sense of what's going on with all of my code. I definitely don't have a lot of experience though, this is my first iPhone app. I'm making a data entry field that is comprised of multiple UITextFields within a UIScrollView. I'll avoid explaining the other details for now, as it seems its a very basic problem. Without a scrollview, the textfields work perfectly. I can touch the textfield and the keyboard or picker view show up appropriately. When I add the textfields to a scrollview, the scrollview works, but then the text fields don't receive my touches. Here's the key: When 'User Interaction' is ENABLED, the scrollview works but the textfield touches are NOT registered. When 'User Interaction' is DISABLED, the scrollview doesn't work, but the textfield touches ARE registered and the keyboard/picker pops up. From the other posts I have seen people creating subclasses and overriding the touches in a separate implementation. I've seen people using custom content views (subviews?), I've seen some solutions that are now obsolete since the APIs have changed in newer versions of the SDK, and I am just completely stuck. I will leave out my code for now, because maybe there is a solution that someone has without requiring my code. If someone needs to see my code, I will put it up. My app is being written in the 3.1.3 SDK. If anyone has ANY information that could help, it would be so greatly appreciated.

    Read the article

  • Swiping Images with Page Control in Iphone

    - by lakesh
    I am trying to make practice app where i can scroll images with page control. I am able to scroll images and able to include the page control. But the problem i face is i am not able to interlink the two. Meaning to say when I scroll the images, the page control is not affected and when i change the page control, the scrolling of the images is unaffected. I have referred to this: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/ for the scrolling with page control. Viewcontroller.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIScrollViewDelegate>{ UIScrollView *scrollView; UIPageControl *pageControl; BOOL pageControlBeingUsed; } @property (nonatomic, retain) IBOutlet UIScrollView *scrollView; @property (nonatomic, retain) IBOutlet UIPageControl *pageControl; - (IBAction)changePage; @end Viewcontroller.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize scrollView,pageControl; - (void)viewDidLoad { [super viewDidLoad]; NSArray *images = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1.jpeg"],[UIImage imageNamed:@"2.jpeg"],[UIImage imageNamed:@"3.jpeg" ], nil]; self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * images.count, self.scrollView.frame.size.height); for (int i = 0; i < images.count; i++) { CGRect frame; frame.origin.x = self.scrollView.frame.size.width * i; frame.origin.y = 0; frame.size = self.scrollView.frame.size; UIImageView* imgView = [[UIImageView alloc] init]; imgView.image = [images objectAtIndex:i]; imgView.frame = frame; [scrollView addSubview:imgView]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.scrollView = nil; } - (void)scrollViewDidScroll:(UIScrollView *)sender { // Update the page when more than 50% of the previous/next page is visible CGFloat pageWidth = self.scrollView.frame.size.width; int page = floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; self.pageControl.currentPage = page; } - (IBAction)changePage{ // update the scroll view to the appropriate page CGRect frame; frame.origin.x = self.scrollView.frame.size.width * self.pageControl.currentPage; frame.origin.y = 0; frame.size = self.scrollView.frame.size; [self.scrollView scrollRectToVisible:frame animated:YES]; pageControlBeingUsed = YES; } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { pageControlBeingUsed = NO; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { pageControlBeingUsed = NO; } @end Need some guidance on this... Thanks..

    Read the article

  • How to resize UILabel text after zooming UIScrollview zoomable

    - by netadictos
    I have an UIScrollview that is zoomable, the subview is one UIView (viewTexto) that contains an UILabel inside (messageLabel). This is the code - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollViewtmp{ return viewTexto; } -(void)scrollViewDidEndZooming:(UIScrollView *)scrollViewtmp withView:(UIView *)view atScale:(float)scale{ messageLabel.contentScaleFactor=scale; [scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, messageLabel.frame.origin.y + messageLabel.frame.size.heightt)]; } With this code I can zoom, and the text is not blurry, there is no horizontal scroll but the size of the UILabel continues to be too large, so it is cut. I need that the width of the UILabel adopts to the scrollView width again as at the beginning. I have read any question about UIScrollViews in SO and having found exactly what I need.

    Read the article

  • How i display my scrollView instaed of splash screen?

    - by Rajendra Bhole
    HI, I develop an application in which i want to implement the splash screen, on that splash screen i want to bind the scrollView and UIImage. My code as follow, -(void)splashAnimation{ window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; //scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; scrollView = [[UIScrollView alloc] initWithFrame:[window bounds]]; scrollView.pagingEnabled = NO; scrollView.bounces = NO; UIImage *image = [UIImage imageNamed:@"splash.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.userInteractionEnabled = NO; [scrollView addSubview:imageView]; [scrollView setDelegate:self]; //[scrollView release]; /* window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; UIView *splashView = [[UIView alloc] initWithFrame:[window bounds]]; UIImage *image = [UIImage imageNamed:@"splash.png"]; [splashView addSubview: [[UIImageView alloc] initWithImage:image]]; [window addSubview:splashView]; [window makeKeyAndVisible]; [window removeFromSuperview]; } - (void)applicationDidFinishLaunching:(UIApplication *)application { [self splashAnimation]; [self initControllers]; [window addSubview:[mainTabBarController view]]; [window makeKeyAndVisible]; } On my given code the one blank window comes up and stay on. I want to on that blank screen bind my splash.png.

    Read the article

  • Android ScrollView Not Scrolling Correctly

    - by user3133534
    I've been making my way through thenewboston's android tutorials and I'm stuck on number 35. There is supposed to be a scroll bar that takes up a weight of 30 at the top of the app. There are 6 textview/edittext field groups in the code, but I deleted 5 for simplicity. My problem is that all of the text and text boxes appear on the page and are not confined to the given weight (they all just show up on the page). Has anyone else had this problem or know how to fix it? Please, I'm new to stackoverflow. If you think this is a stupid question, please explain to me why and how I can ask it better. Here is what it looks like: http://imgur.com/gJmOgqk <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:weightSum="100" > <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="30" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > </EditText> </LinearLayout> </ScrollView> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="40" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="30" android:orientation="vertical" > <AnalogClock android:id="@+id/analogClock1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout>

    Read the article

  • ScrollView content async downloading problem

    - by Newbee
    Hi! I have UIScrollView with lots of UIImageView inside. In the loadView method I assign some temporary image for each of subview UIImageView images and starts several threads to async download images from internet. Each thread downloads and assign images as follows: NSData *data = [NSData dataWithContentsOfURL:URL]; UIImage *img = [UIImage imageWithData:data]; img_view.image = img; Here is the problem - I expects picture will changed after each image downloaded by I can see only temporary images until all images will downloads. UIScrollView still interact while images downloads - I can scroll temporary images inside it and see scrollers and nothing blocks run loop, but downloaded images doesn't updates.. What I tried to do: Call sleep() in the download thread -- not helps. Call setNeedsDisplay for each ImageView inside ScrollView and for ScrollView -- not helps. What's wrong ? Thanks. Update. I tried some experiments with number of threads and number of images to download. Now I'm sure -- images redraws only when thread finished. For example - if I load 100 images with one thread -- picture updates one time after all images downloads. If I increase number of threads to 10 -- picture updates 10 times -- 10 images appears per update. One more update. I fixed problem by staring new thread from the downloading threads each time one image downloaded and exit current thread (instead of download several images in one thread in the cycle and exit thread only when all downloaded). Obviously it's not a good solution and there must be right approach.

    Read the article

  • while I scroll between the layout it takes too long to be able to scroll between the gallerie's pictures. Is there any way to reduce this time?

    - by Mateo
    Hello, this is my first question here, though I've being reading this forum for quite a while. Most of the answers to my doubts are from here :) Getting back on topic. I'm developing an Android application. I'm drawing a dynamic layout that are basically Galleries, inside a LinearLayout, inside a ScrollView, inside a RelativeLayout. The ScrollView is a must, because I'm drawing a dynamic amount of galleries that most probably will not fit on the screen. When I scroll inside the layout, I have to wait 3/4 seconds until the ScrollView "deactivates" to be able to scroll inside the galleries. What I want to do is to reduce this time to a minimum. Preferably I would like to be able to scroll inside the galleries as soon as I lift my finger from the screen, though anything lower than 2 seconds would be great as well. I've being googling around for a solution but all I could find until now where layout tutorials that didn't tackle this particular issue. I was hoping someone here knows if this is possible and if so to give me some hints on how to do so. I would prefer not to do my own ScrollView to solve this. But if that is the only way I would appreciate some help because I'm not really sure how would I solve this issue by doing that. this is my layout: public class PicturesL extends Activity implements OnClickListener, OnItemClickListener, OnItemLongClickListener { private ArrayList<ImageView> imageView = new ArrayList<ImageView>(); private StringBuilder PicsDate = new StringBuilder(); private CaWaApplication application; private long ListID; private ArrayList<Gallery> gallery = new ArrayList<Gallery>(); private ArrayList<Bitmap> Thumbails = new ArrayList<Bitmap>(); private String idioma; private ArrayList<Long> Days = new ArrayList<Long>(); private long oldDay; private long oldThumbsLoaded; private ArrayList<Long> ThumbailsDays = new ArrayList<Long>(); private ArrayList<ArrayList<Long>> IDs = new ArrayList<ArrayList<Long>>(); @Override public void onCreate(Bundle savedInstancedState) { super.onCreate(savedInstancedState); RelativeLayout layout = new RelativeLayout(this); ScrollView scroll = new ScrollView(this); LinearLayout realLayout = new LinearLayout(this); ArrayList<TextView> texts = new ArrayList<TextView>(); Button TakePic = new Button(this); idioma = com.mateloft.cawa.prefs.getLang(this); if (idioma.equals("en")) { TakePic.setText("Take Picture"); } else if (idioma.equals("es")) { TakePic.setText("Sacar Foto"); } RelativeLayout.LayoutParams scrollLP = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); layout.addView(scroll, scrollLP); realLayout.setOrientation(LinearLayout.VERTICAL); realLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); scroll.addView(realLayout); TakePic.setId(67); TakePic.setOnClickListener(this); application = (CaWaApplication) getApplication(); ListID = getIntent().getExtras().getLong("listid"); getAllThumbailsOfID(); LinearLayout.LayoutParams TakeLP = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); realLayout.addView(TakePic); oldThumbsLoaded = 0; int galler = 100; for (int z = 0; z < Days.size(); z++) { ThumbailsManager croppedThumbs = new ThumbailsManager(Thumbails, oldThumbsLoaded, ThumbailsDays.get(z)); oldThumbsLoaded = ThumbailsDays.get(z); texts.add(new TextView(this)); texts.get(z).setText("Day " + Days.get(z).toString()); gallery.add(new Gallery(this)); gallery.get(z).setAdapter(new ImageAdapter(this, croppedThumbs.getGallery(), 250, 175, true, ListID)); gallery.get(z).setOnItemClickListener(this); gallery.get(z).setOnItemLongClickListener(this); gallery.get(z).setId(galler); galler++; realLayout.addView(texts.get(z)); realLayout.addView(gallery.get(z)); } Log.d("PicturesL", "ListID: " + ListID); setContentView(layout); } private void getAllThumbailsOfID() { ArrayList<ModelPics> Pictures = new ArrayList<ModelPics>(); ArrayList<String> ThumbailsPath = new ArrayList<String>(); Pictures = application.dataManager.selectAllPics(); long thumbpathloaded = 0; int currentID = 0; for (int x = 0; x < Pictures.size(); x++) { if (Pictures.get(x).walkname == ListID) { if (Days.size() == 0) { Days.add(Pictures.get(x).day); oldDay = Pictures.get(x).day; IDs.add(new ArrayList<Long>()); currentID = 0; } if (oldDay != Pictures.get(x).day) { oldDay = Pictures.get(x).day; ThumbailsDays.add(thumbpathloaded); Days.add(Pictures.get(x).day); IDs.add(new ArrayList<Long>()); currentID++; } StringBuilder tpath = new StringBuilder(); tpath.append(Pictures.get(x).path.substring(0, Pictures.get(x).path.length() - 4)); tpath.append("-t.jpg"); IDs.get(currentID).add(Pictures.get(x).id); ThumbailsPath.add(tpath.toString()); thumbpathloaded++; if (x == Pictures.size() - 1) { Log.d("PicturesL", "El ultimo de los arrays, tamaño: " + Days.size()); ThumbailsDays.add(thumbpathloaded); } } } for (int y = 0; y < ThumbailsPath.size(); y++) { Thumbails.add(BitmapFactory.decodeFile(ThumbailsPath.get(y))); } } I had a memory leak on another activity when screen orientation changed that was making it slower, now it is working better. The scroller is not locking up. But sometimes, when it stops scrolling, it takes a few seconds (2/3) to disable itself. I just want it to be a little more dynamic, is there any way to override the listener and make it stop scrolling ON_ACTION_UP or something like that? I don't want to use the listview because I want to have each gallery separated by other views, now I just have text, but I will probably separate them with images with a different size than the galleries. I'm not really sure if this is possible with a listadapter and a listview, I assumed that a view can only handle only one type of object, so I'm using a scrollview of a layout, if I'm wrong please correct me :) Also this activity works as a preview or selecting the pictures you want to view in full size and manage their values. So its working only with thumbnails. Each one weights 40 kb. Guessing that is very unlikely that a user gets more than 1000~1500 pictures in this view, i thought that the activity wouldn't use more than 40~50 mb of ram in this case, adding 10 more if I open the fullsized view. So I guessed as well most devices are able to display this view in full size. If it doesn't work on low-end devices my plan was to add an option in the app preferences to let user chop this view according to some database values. And a last reason is that during most of this activity "life-cycle" (the app has pics that are relevant to the view, when it ends the value that selects which pictures are displayed has to change and no more pictures are added inside this instance of this activity); the view will be unpopulated, so most of the time showing everything wont cost much, just at the end of its cycle That was more or less what I thought at the time i created this layout. I'm open to any sort of suggestion or opinion, I just created this layout a few days ago and I'm trying to see if it can work right, because it suits my app needs. Though if there is a better way i would love to hear it Thanks Mateo

    Read the article

  • Loading images to UIScrollview crashes

    - by Icky
    Hello All. I have a Navigationcontroller pushing a UIViewController with a scrollview inside. Within the scrollview I download a certain number of images around 20 (sometimes more) each sized around 150 KB. All these images are added to the scrollview so that their origin is x +imageSize and the following is sorted right to the one before. All in all I think its a lot of data (3-4 MB). On an I pod Touch this sometimes crashes, the IPhone can handle it once, if it has to load the data again (some other images) , it crashes too. I guess its a memory issue but within my code, I download the image, save it to a file on the phone as NSData, read it again from file and add it to a UIImageview which I release. So I have freed the memory I allocated, nevertheless it still crashes. Can anyone help me out? Since Im new to this, I dont know the best way to handle the Images in a scrollview. Besides I create the controller at start from nib, which means I dont have to release it, since I dont use alloc - right? Code: In my rootviewcontroller I do: -(void) showImages { [[self naviController] pushViewController:imagesViewController animated:YES]; [imagesViewController viewWillAppear:YES]; } Then in my Controller handling the scroll View, this is the method to load the images: - (void) loadOldImageData { for (int i = 0; i < 40 ; i++) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"img%d.jpg", i]]; NSData *myImg = [NSData dataWithContentsOfFile:filePath]; UIImage *im = [UIImage imageWithData:myImg]; if([im isKindOfClass:[UIImage class]]) { NSLog(@"IM EXISTS"); UIImageView *imgView = [[UIImageView alloc] initWithImage:im]; CGRect frame = CGRectMake(i*320, 0, 320, 416); imgView.frame = frame; [myScrollView addSubview:imgView]; [imgView release]; //NSLog(@"Adding img %d", i); numberImages = i; NSLog(@"setting numberofimages to %d", numberImages); //NSLog(@"scroll subviews %d", [myScrollView.subviews count]); } } myScrollView.contentSize = CGSizeMake(320 * (numberImages + 1), 416); }

    Read the article

  • Create a screen like the iPhone home screen with Scrollview and Buttons

    - by Anthony Chan
    Hi, I'm working on a project and need to create a screen similar to the iPhone home screen: A scrollview with multiple pages A bunch of icons When not in edit mode, swipe through different pages (even I started the touch on an icon) When not in edit mode, tap an icon to do something When in edit mode, drag the icon to swap places, and even swap to different pages When in edit mode, tap an icon to remove it Previously I read from several forums that I have to subclass UIScrollview in order to have touch input for the UIViews on top of it. So I subclassed it overriding the methods to handle touches: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { //If not dragging, send event to next responder if (!self.dragging) [self.nextResponder touchesBegan:touches withEvent:event]; else [super touchesBegan:touches withEvent:event]; } In general I've override the touchesBegan:, touchesMoved: and touchesEnded: methods similarly. Then in the view controller, I added to following code: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; UIView *hitView = (UIView *)touch.view; if ([hitView isKindOfClass:[UIView class]]) { [hitView doSomething]; NSLog(@"touchesBegan"); } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // Some codes to move the icons NSLog(@"touchesMoved"); } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesEnded"); } When I run the app, I have the touchesBegan method detected correctly. However, when I tried to drag the icon, the icon just moved a tiny bit and then the page started to scroll. In console, it logged with 2 or 3 "touchesMoved" message only. However, I learned from another project that it should logged tonnes of "touchesMoved" message as long as I'm still dragging on the screen. (I'm suspecting I have the delaysContentTouches set to YES, so it delays a little bit when I tried to drag the icons. After that minor delay, it sends to signal back to the scrollview to scroll through the page. Please correct me if I'm wrong.) So if any help on the code to perform the above tasks would be greatly appreciated. I've stuck in this place for nearly a week with no hope. Thanks a lot.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >