Android :: How To Scroll To Bottom On Activity Startup?

Jul 22, 2010

I am displaying some data in a ScrollView. On activity startup (method onCreate) I fill the ScrollView with data and want to scroll to the bottom. I tried to use:
getScrollView().fullScroll(ScrollView.FOCUS_DOWN).
This works when I make it as an action on button click but it doesn't work in the onCreate method. Is there any way how to scroll the ScrollView to the bottom on activity startup? That means the view is already scrolled to the bottom when first time displayed.

Android :: How to Scroll to Bottom on Activity Startup?


Android :: Scroll Down - Text Area Get Focus Scroll Little Bit And Also Display Bottom Buttons

Apr 19, 2010

I have text area and and down to that "ok" and "cancel" button. when i click on text area keyboard appear and focus on the text area and buttons get hide behind the keyboard.

I want when text area get focus scroll a little bit and also display the bottom buttons while text area id selected.

View 2 Replies View Related

Application Scroll To First Edit Field On Startup?

Oct 5, 2011

I'm debugging my first Android app and when running in the emulator it seems fine. The main view appears and no edit fields have focus. I see the full screen including the introduction text at the top.

When I start this on my Vodafone 858 Smart phone, the view scrolls down to the first edit field (which is a phone number field) and also pops up the number pad. I have removed the 'focus' tags from my mains.xml, so I do not see why it's scrolling to the first edit field.

Android SDK 2.2 (8)

what I can modify to prevent this?

View 1 Replies View Related

Android :: How Do I Know That Scroll View Is Already Scrolled To Bottom?

May 19, 2010

I have a scrollview and I only want an event to happen if it's already scrolled to the bottom but I can't find a way to check if the scrollview is at the bottom.I have solved it for the opposite; only allow the event to happen if it's already scrolled to the top:ScrollView sv = (ScrollView) findViewById(R.id.Scroll);

View 2 Replies View Related

Android :: Scroll View Force To Bottom

Jun 20, 2010

I would like a ScrollView to start all the way at the bottom. Any methods?

View 2 Replies View Related

Android :: Getting Button To Scroll Into View At Bottom

Sep 8, 2010

I am trying to port an existing iPhone application to android. I wish to have a button scroll into view at the bottom of a GridView to enable the user to load more data from the server. Presently, my solution simply fixes a button at the bottom of the screen instead of having it scroll into view.

Here is my layout code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >
<GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid"
android:layout_width="fill_parent" android:layout_height="wrap_content" android:columnWidth="70dp" android:numColumns="auto_fit" android:verticalSpacing="0dp" android:horizontalSpacing="0dp" android:stretchMode="columnWidth" android:gravity="center" android:background="#000000" />
<Button android:id="@+id/load_more" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Load More" /> </LinearLayout>

Fixing the button at the bottom of the screen won't work because I plan on placing an ad at the bottom. Can anyone either explain conceptually how to get a load more button to scroll into view, or point me to some sample code, OR tell me why this is not idiomatic to Android and what other UI convention it uses to load more data in a GridView?

View 1 Replies View Related

Android :: How To Determine When Scroll View Has Reached Bottom

Apr 9, 2009

I have a TextView inside a ScrollView and I have loaded it with a bunch of text. When the ScrollView gets to the bottom/top I would like to load the TextView with new data BUT there doesn't appear to be any way to find out when you have reached either location. Could some one help me out with this? How can this be done?

View 5 Replies View Related

Android :: Scroll View Alawys Scrolling To Bottom

May 14, 2010

I defined a scrollview with a texteedit in my layout:
<ScrollView android:fillViewport="true"
android:layout_marginBottom="50dip"
android:id="@+id/start_scroller"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:fadingEdge="none">
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TextView>
</ScrollView>
I add text to this ScrollView with the following method:public void writeToLogView(String textMsg) {
if (text.getText().equals("")) {
text.append(textMsg);
} else {
text.append("
" + textMsg);
scroller.scrollBy(0, 1000000); As you can see i append the text and try to scroll to the bottom of the ScrollView. Unfortunately this doesn't worked correctly. It scrolls down, but not always, and not always to the bottom. Any hints?

View 2 Replies View Related

Android : Move Scroll At Bottom Of List Programmatically?

Mar 29, 2010

I after calling notifydatasetchanged();

i want to move scroll of list to the bottom of list so that user could see last record in the listview.actually i am writing Chat module so for that purpose i need latest record at the bottom of list. can any one guide me how to achieve this?

View 1 Replies View Related

Sprint HTC Hero :: Is There App That Gives You Bottom Scroll Bar

Jun 24, 2010

I liked the bottom dock of LauncherPro, but I don't want to re-do all of my home pages. Any apps out there that give you the bottom dock and JUST the dock?

View 12 Replies View Related

Android :: Show Scroll View With Button Anchored Bottom Of Screen?

Mar 18, 2010

I'm trying to show a ScrollView with a button anchored to bottom of screen. This is coded programmatically (without using XML layout for now). The trouble is when the ScrollView has many items (requiring scrolling), it prevents the button at the bottom from showing. The bottom button is sort of pushed off the screen. Look at the code below. I have a TODO which mentions a workaround to specify the exact pixel height of the ScrollView, but this is not a good solution. If you change the for loop to add only 2 buttons, then the bottom button will show. So how do I make the ScrollView show a scrolling list, with the bottom button in view, and without specifying an exact size of the ScrollView? I've seen some discussions here:

http://groups.google.com/group/android-developers/browse_thread/threa http: //groups. google.com /group/ android-developers/browse_thread/threa But I don't know how to apply these to my situation.package com.test.ScrollViewTest; import android.app.Activity; import android.os.Bundle; import android. view. Gravity ; import android.view. ViewGroup. MarginLayoutParams; import android.widget.Button; import android. widget.ImageView; import android .widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.TextView; public class MyScrollViewTest extends Activity @Override public void onCreate(Bundle savedInstanceState) super. onCreate (savedInstanceState); LinearLayout ll = new LinearLayout(this); // the main layout of the screen ll.setOrientation (LinearLayout.VERTICAL); TextView tv1 = new TextView(this); tv1.setText("First line of text"); TextView tv2 = new TextView(this); tv2.setText("Second line of text"); ll.addView(tv1); ll.addView(tv2); ScrollView sv = new ScrollView(this);// You can only add one child (usually a layout) to a scrollview, // otherwise you get exception: "ScrollView can host only one direct child" LinearLayout ll2 = new LinearLayout(this); ll2.setOrientation(LinearLayout.VERTICAL); * TODO: PROBLEM HERE: You cannot use WRAP_CONTENT for height, because * the layout below the scrollView will not show (it's sort of pushed * off the screen - even if a margin is specified). * An alternate value of 300 works OK (remove the bottom margin too).* But this is only suitable for screen size 320x480 in portrait mode.LinearLayout.LayoutParams params Linear = new LinearLayout.LayoutParams( LinearLayout. Layout Params.FILL_PARENT, Linear Layout.LayoutParams.WRAP_CONTENT /*300*/); Add 50 pixel margin to bottom of scrollview (this margin doesn't scroll) paramsLinear.bottomMargin = 50;sv.addView(ll2); // Add some stuff to scrollView to test its depth // (it should leave a margin at bottom of screen) for (int i = 1; i < 10; i++) { TextView textView = new TextView(this) ;textView.setText ("Text View " + i); linearLayout.LayoutParams p = new LinearLayout .LayoutParams (Linear Layout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

ll2.addView (textView, p); button buttonView = new Button(this); buttonView. setText ("Button " + i);ll2.addView(buttonView, p); ll.addView(sv, paramsLinear); RelativeLayout rl = new RelativeLayout(this); RelativeLayout.LayoutParams paramsRelative = new lative Layout. LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout .Layout Params .WRAP_CONTENT); // Make the button anchored to the bottom of the screen.// But this doesn't work when the ScrollView has a scrolling list of items. Why? params Relative .addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); rl.setLayout Params (params Relative) ;

View 5 Replies View Related

Motorola Droid :: Quick Scroll To Bottom Bug Or Feature?

Nov 12, 2009

I assume that I am not the only Droid's owner who has this weird experience with the device: sometimes when I touch on a list (e.g., Apps listed on Market) or a web-page. The list or page will rapidly scroll all the way to the bottom of the list or page. Although I experience this at least a couple times every day, I am unable to reproduce this phenomenon at will.Does anyone know what cause this? Is it a bug?

View 15 Replies View Related

Samsung Moment :: Is It Possible To Quickly Scroll To Top / Bottom Of Page

Mar 30, 2010

On some website it takes a while to scroll the page. Is it possible to do it with one click or one scroll?

View 3 Replies View Related

Motorola Droid X : Instantly Scroll To Bottom / Top Of Page / App List?

Jul 26, 2010

Is there a touchscreen gesture or a keyboard shortcut to scroll directly to the top or bottom of a list or webpage (since we can bring up the keyboard by holding down menu)?

View 2 Replies View Related

Samsung Moment :: Scroll To Bottom Of Page With Single Flick Of Finger?

Dec 22, 2009

Sometimes when scrolling down on a page (using my finger to scroll) the page will scroll all the way to the bottom of the page with a single flick of the finger. Am I unintentionally doing a specific gesture with my finger that causes this to happen? Or is this just a bug at this point?

View 9 Replies View Related

Android :: Soft Keyboard On Activity Startup

Jan 12, 2010

I am struggling trying to have the soft keyboard appear in a search screen and from the looks of numerous pleas on various forums, I am not the only one. I have tried many variants, culling from the byzantine attempts of those others.

InputMethodManager imm = (InputMethodManager) getSystemService
(Context.INPUT_METHOD_SERVICE); imm.showSoftInput (query, 0);
(for 0, substitute InputMethodManager.SHOW_FORCED or InputMethodManager.SHOW_IMPLICIT.)

The problem seems to be that showSoftInput doesn't work from onCreate. This is a very common need. Surely there is a reasonable solution to this problem, or is it botched here?

View 3 Replies View Related

Android :: Adding View To Bottom Of Layout Inside Scroll View

Mar 10, 2010

So my layout looks basically like this:
<ScrollView>
<RelativeLayout>
<BunchOfViews/>
<ImageView android:layout_alignParentBottom="true"/>
</RelativeLayout>
</ScrollView>
I have the ScrollView so all of the layout always is visible no matter the height of the screen. The problem is that on a very high screen, I still want my imageview to be at the bottom. However, a child of a ScrollView dont seem to have a defined bottom. The View is placed at the top of the layout. How can I solve this problem in a neat way?

View 4 Replies View Related

Android :: Show Dialog When Application / Activity Startup

Aug 24, 2010

Can we show the dialog when our application/activity startup?

View 4 Replies View Related

Android :: Specify Which Item Gets Default Focus On Activity Startup?

Apr 11, 2009

How can you specify which item gets the default focus on Activity startup? Using requestFocus programmatically does not work. On setContextView the first focusable item listed in the XML is given the default focus. When using RelativeLayout, the first item listed is not always the desired item or necessarily on top.

View 3 Replies View Related

Android :: Simple Program - Class Extends Activity At Startup

Oct 1, 2010

I have a simple activity program in android. Basically the class just extends Activity.
But when I start it I get a ClassCastException in the constructor of my class. I don't even have a constructor defined, so it must be in the constructor of the superclass which is Activity. Unfortunately the debugger doesn't give any detailed information on what class it is trying to cast. Here is the stacktrace:

Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread$PackageInfo.makeApplication(boolean, Instrumentation) line: 649
ActivityThread.handleBindApplication(ActivityThread$AppBindData) line: 4232
ActivityThread.access$3000(ActivityThread, ActivityThread$AppBindData) line: 125
ActivityThread$H.handleMessage(Message) line: 2071
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]

And when I look into this runtimeexception I get:

detailMessage "Unable to instantiate application com.test.MyApp: java.lang.ClassCastException: com.test.MyApp" (id=830067694464)
The only code is:
package com.test;
import android.app.Activity;
public class MyApp extends Activity {
}

View 3 Replies View Related

Android :: Trap In TabHost When AsyncTask Delays Set Content View At Activity Startup

Nov 3, 2009

I've got a tab host activity started from a home screen shortcut. When my application starts it downloads information from a server using an AsyncTask. In the onPostExecute method of the AsyncTask I call setContentView to display the TabHost.When I start the homescreen shortcut by tapping on the shortcut using my finger everything works as expected, I download the information from the server and display the TabHost with the information in the tabs. However starting the application by navigating to the shortcut with the mouse wheel and then clicking on the shortcut with the mouse wheel leads to a trap in the framework code as soon as my application starts. This looks like a simple fix since mCurrentView is null at the time that this method is called - can this issue be addressed? Does anyone know of any workarounds?

View 5 Replies View Related

Android : Position An Overlaying Activity At Bottom?

Apr 8, 2010

I have an activity that comes up over another activity. I'd like to position the overlying activity at the bottom of the screen without using an absolute layout, just like the soft keyboard.

I can't figure out if this can be done in an XML layout, and if so, where does it go?

I have a theme created, and the manifest is set to use it (this works). But overlaying activity is always positioned in the center of the screen. This is what I have. code...

How do I get the layout to show up aligned to the bottom for the overlaying window?

View 2 Replies View Related

Android : Get Scroll Position In A List Activity?

Mar 23, 2009

I'm trying to get the scroll position on a ListActivity. Here is what I'm trying to do: I have a list activity that is populated from an XML file. Another thread downloads all pictures so the user can see the list while the thread is still downloading the files.

What I'm trying to do is when the thread finishes getting all pics it reads the listview scroll position, refresh the listview and scroll to that position again.

ListView main = getListView(); <-- not sure if I'm really getting the ListView this way. int scY = main.getScrollY(); Log.d("Scroll", scY + " "); <--- this is printing zero even when at the moment I run this I already scrolled the list. setListAdapter(listadapter); main.scrollTo(0, scY);

View 10 Replies View Related

Android :: Fix View At Bottom Of Screen In An Activity In Droid?

Jul 23, 2010

I want to fix a view at the bottom of the screen.How can i do that?

View 1 Replies View Related

Android : Save Scroll Position - When Activity Returns?

Jul 8, 2009

How can I save and load the scroll position of a listview that is destroyed/hidden/paused.

View 3 Replies View Related

Android :: How To Create Bottom-Top Animation When Close / Stop Activity?

Oct 10, 2009

How can I create a Slide-Bottom-To-Top animation when close/stop an activity in android application?

View 1 Replies View Related

Android :: Show Adds At Bottom Of An Activity(with Custom View)?

Mar 29, 2010

I need show ads in my application. Ads in my custom view must move from bottom of screen with animation. How can I add my view in bottom of screen?

View 2 Replies View Related

Motorola Droid :: Startup Programs - Edit What Loads On Startup

Jan 7, 2010

Every time I start my phone it seems that every program in the app catalog starts up. Until I activate the Advanced Task Killer and shut them all down, the thing runs like a hog. I have quite a few programs installed, but I dont use them all all of the time. Why do they all start up and is there any way beside the ATK to stop them? Is there any way to modify the startup files?

View 4 Replies View Related

Android :: Why Does TextView.setText Cause Enclosing Scroll View To Scroll?

Jun 24, 2010

I've got this odd problem which is happening on 1.6, 2.2, and a MyTouch 3G Slide (which is API #7, and listed as "2.1-Update1" in the Android Device Chooser). If anyone can explain what I'm doing wrong & how to fix it (or possibly confirm that this is an Android bug)The basic idea for my app is to make a stopwatch-sort of thing, in that the user can tap a button to start a timer, then tap it again to stop (pause) the timer; further taps alternate between resuming the timer and pausing the timer.I've got a top-level ScrollView which contains a RelativelLayout, which contains a bunch of widgets. The first widget is a HUGE button (so that it's easy to press), which pushes all my other widgets below the bottom of the screen. This is intentional, as I want to rely on the ScrollView (and an on-screen reminder to the user) to make the rest of the input options available.I've got a simple state-machine type setup, where mState is the current mode (STATE_ TIMER_ NOT_ STARTED before the user presses any buttons, RUNNING after the first press, and then PAUSED after the second, back to RUNNING after the third, etc, etc).

All this works great EXCEPT that when the timer is running, and the user presses the start/stop/resume button again, the ScrollView will scroll down a ways. I am NOT issuing this command (I don't even have a reference to ScrollView object), and I'm not sure why it's doing this.

REPRO:Compile + run the below samples. When the app starts, press the 'Start Timing' button. Use your thumb (or the mouse) to touch-drag the screen upwards (so you can see the RatingBar), then drag it back downwards (so the button is again completely on-screen). Tap the button (which now reads 'PauseTiming') again, and it'll jump down a bit. It should NOT be jumping/scrolling down, since there's no statement (that I can see) that tells it to scroll down. As near as I can tell, it's the setText that causes the scrolling ( when I comment those lines out, no scrolling occurs).WHAT I'M ASKING FOR:if I'm doing something dumb & you could point out what it is, I'd really appreciate it! I wonder if 'touch mode' might have something to do with this, since it does NOT appear to happen (in the emulator) when I use the mouse's scroll wheel to move the panel upwards (i.e.,instead of the simulated finger-dragging). I can't find a whole lot on touch-mode, and nothing specific on focus/selection in touch mode within a ScrollView if you can confirm that this error occurs for you too, that would be ok, too (since misery loves company.AHEM I mean, since it might help confirm that it's not just me MyTestApp.java package bug.android.scrollview;
import android.app.Activity;
import android.os.Bundle;
import android.text.format.Time;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
public class MyTestApp extends Activity {
public final static int STATE_TIMER_NOT_STARTED = 1;
public final static int STATE_TIMER_RUNNING = 2;
public final static int STATE_TIMER_PAUSED = 3;
private int mState;
Time t = new Time();
private Time data = new Time();
private Button btnStartStopResume;
private TextView lblSpacer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_time_entry);
btnStartStopResume = (Button) findViewById(R.id.btnStartStopResume);
// Set the button's size so that the other info will also be visible
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE))
.getDefaultDisplay();
// This is such a hack, but the windowScroller doesn't appear to
// have a height at this point in the lifecycle (nor in 'onResume' :( )
btnStartStopResume.setHeight(display.getHeight() - 200);
lblSpacer = (TextView) findViewById(R.id.lblSpacer);
reset();
} public void doStartStopResume(View v) {
if (mState == MyTestApp.STATE_TIMER_NOT_STARTED) {
mState = MyTestApp.STATE_TIMER_RUNNING;
data.setToNow();
} else if (mState == MyTestApp.STATE_TIMER_RUNNING) {
mState = MyTestApp.STATE_TIMER_PAUSED;
String s = getString(R.string.add_scroll_down_to_add);
lblSpacer.setText(s);
} else if (mState == MyTestApp.STATE_TIMER_PAUSED) {
mState = MyTestApp.STATE_TIMER_RUNNING;
public void doReset(View v) {
}public void doNewRunClick(View v) {
public void doAddTiming(View v) {
public void reset() {
mState = STATE_TIMER_NOT_STARTED;
new_time_entry.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/windowScroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
> <RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
> <Button
android:id="@+id/btnStartStopResume"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:text="Start Timing"
android:textSize="40dp"
android:height="290dp"
android:onClick="doStartStopResume" />
<TextView
android:id="@+id/lblSpacer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btnStartStopResume"
android:layout_centerHorizontal="true"
android:text="@string/add_scroll_down_for_more" />
<TextView
android:id="@+id/lblTimeStartLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lblSpacer"
android:layout_alignParentLeft="true"
android:clickable="true"
android:onClick="adjustStartTime"
android:text="Start of this run:"
android:textSize="8dp" />
<TextView
android:id="@+id/lblTimeStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/lblTimeStartLabel"
android:layout_alignParentLeft="true"
android:clickable="true"
android:onClick="adjustStartTime"
android:text="--:--:-- --"
android:textColor="#FFFFFF"
android:textSize="26dp" />
<TextView
android:id="@+id/lblElapsedLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/lblSpacer"
android:layout_alignRight="@id/lblSpacer"
android:layout_marginRight="5dp"
android:text="Elapsed Time:"
android:textSize="8dp" />
<TextView
android:id="@+id/lblTimeElapsed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/lblElapsedLabel"
android:layout_alignRight="@id/lblSpacer"
android:layout_marginRight="5dp"
android:textColor="#99ff66"
android:text="-- m -- sec"
android:textSize="26dp"
android:layout_marginBottom="10dip"/>
<CheckBox
android:id="@+id/chkNewRun"
android:onClick="doNewRunClick"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lblTimeElapsed"
android:text="This is a new run of timings"
android:layout_marginBottom="10dip" />

<TextView
android:id="@+id/lblIntensity"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Intensity (1 = none 5 = max)"
android:layout_below="@id/chkNewRun" />
<RatingBar
android:id="@+id/rbIntensity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/lblIntensity"
android:numStars="5"
android:rating="2"
android:layout_marginBottom="5dip" />

<TextView
android:id="@+id/lblNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Notes:"
android:layout_below="@id/rbIntensity" />
<EditText
android:id="@+id/txtNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_below="@id/lblNotes"
android:layout_marginBottom="10dip" />
<Button
android:id="@+id/btnReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtNotes"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:text="Reset"
android:onClick="doReset" />
<Button
android:id="@+id/btnOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtNotes"
android:layout_toRightOf="@id/btnReset"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:text="Add Timing To List"
android:onClick="doAddTiming" />
</RelativeLayout>
</ScrollView>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Timer</string>
<string name="dlg_edit_timing_title">Edit A Timing</string>
<string name="add_scroll_down_for_more">< Scroll down for more options! ></string>
<string name="add_scroll_down_to_add">< Scroll down to save this timing! ></string>
<string name="start_timing">Start Timing
</string>
<string name="stop_timing">Pause Timing
</string>
<string name="resume_timing">Resume Timing
</string>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bug.android.scrollview"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MyTestApp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="5" />
</manifest>
UPDATE 1: Adding if( btnStartStopResume.isInTouchMode() )
Toast.makeText(this, "TOUCH MODE", 2000);
elseToast.makeText(this, "NOT touch mode", 2000);
then setting breakpoints in the debugger confirms that the button is always in touch mode (regardless of whether I finger-drag the panel up/down, or mouse-wheel it up/down). So it's a combination of being in touch-mode AND finger-dragging the panel after the 2nd button-press (i.e, when the app is in 'stopped/paused timing' mode) that's causing the odd extra-timing in subsequent pauses.
UPDATE 2:
I just noticed that it's scrolling down to the EditText, and no further. It looks like when you move the panel down the EditText gets the selection, and after the click event the ScrollView scrolls back to the thing that has the selection. Seems to explain why the mouse-wheel approach doesn't have this problem (it moves the selection/focus back up to the button).

View 1 Replies View Related

Android :: Scroll To Last Line Of Table Layout Within Scroll View

Jun 21, 2010

I want to have a dynamic table, with rows added over time as a result of user interaction, using a TableLayout inside a ScrollView. This works fine, but when I want to scroll to the end of the table using fullScroll(), it always leaves out the last line; that is, it scrolls so that the one before the last one is visible. The last line is visible when scrolling manually, and the scrollbar is correct too.I'm of course open to suggestions as to how to make a better layout out of this; but I'm specifically interested in understanding why fullScroll() behaves that way. Should I give it a different parameter, or use something else altogether? Or does it do that because the newly added line isn't yet visible somehow? (if so, how can I solve that?) Or did I miss some other obvious thing?The following code replicates the problem: TestActivity.java:
package com.example.android.tests;
import java.util.Random;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class TestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
((Button) findViewById(R.id.AddRow)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
Random rnd = new Random();
TableRow nr = new TableRow(v.getContext());
for (int c=0; c<3; c++) {
TextView nv = new TextView(v.getContext());
nv.setText(Integer.toString(rnd.nextInt(20)-10));
nr.addView(nv);
}((TableLayout) findViewById(R.id.Table)).addView(nr);
// Scrolls to line before last - why?
((ScrollView) findViewById(R.id.TableScroller)).fullScroll(View.FOCUS_DOWN);
}main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="Add Row"
android:id="@+id/AddRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<ScrollView
android:id="@+id/TableScroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/AddRow"
android:layout_alignParentTop="true" >
<TableLayout
android:id="@+id/Table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1,2" />
</ScrollView>
</RelativeLayout>
Edit: for reference, I implemented Romain Guy's solution as follows:In TestActivity.java, replace:
// Scrolls to line before last - why?
((ScrollView) findViewById(R.id.TableScroller)).fullScroll(View.FOCUS_DOWN);
// Enqueue the scrolling to happen after the new row has been layout
((ScrollView) findViewById(R.id.TableScroller)).post(new Runnable() {
public void run() {
((ScrollView) findViewById(R.id.TableScroller)).fullScroll(View.FOCUS_DOWN);

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved