Android :: Defining A Scroll View Without Setting Its Height

Aug 24, 2010

I created a ScrollView and want it to expand to the available space, without having to set a fixed height (i.e. "250px") for it. As such, I created a Relative Layout. The basic outline follows: Code...

Android :: Defining a Scroll View without setting its height


Android :: Scroll View Containing Text View Does Not Scroll

Apr 14, 2010

I have a textview displaying many individual words, each word is a link using Spans and setMovement Method( 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?

View 1 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

Android :: Scroll View With Horizontal Scroll Support?

Mar 12, 2009

It looks like the standard ScrollView does not support horizontal scroll. Has anyone implement a ScrollView with horizontal scroll support? It would be appreciated if you can share it.

View 6 Replies View Related

Android :: Synchronise Scroll View Scroll Positions

Oct 16, 2010

I have 2 ScrollViews in my android layout. How can I synchronise their scroll positions?

View 1 Replies View Related

Android :: Scroll View Scroll Time Out ?

Nov 20, 2009

is there no way to change the timeout to scroll in ScrollView? In the source, it's set to: static final int ANIMATED_SCROLL_GAP = 250; so any drags will be blocked for 250ms. This has the appearance of the ScrollView being stuck for a bit before it moves. This makes small scroll gestures difficult to work with. There's no way around this?

View 9 Replies View Related

Android :: Reset Scroll In Scroll View

Sep 17, 2010

I have a ScrollView (and a LinearLayout within it) set as main content. When the user scrolls the view further down, and then if I replace it's child (LinearLayout) with another LinearLayout, the view remains in the scrolled positioned.How do I reset the ScrollView back to coordinate 0?

View 1 Replies View Related

Android :: List View Fixed Height Of Child View

Jul 27, 2010

Please advice how to set fixed heigh (in dip) for the child view of ListView component? I am using relative layout as root layout for the child view when I set backgoround image to relative layout it becomes very height (maybe because backgoround picture is large) and I want to set precisely the height in dp.

View 1 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 :: Scroll View Doesn't Resize - Content Of Child View Changes

Aug 18, 2010

I have a WebView inside the ScrollView. The content of WebView dyanamically changes when it displays different html page. I have the following issue: For example I have A.html, and B.html. The content of B.html is larger than A.html, so the page is longer. When WebView load B.html, the ScrollView stretches its size to enable itself scroll for B.html, then if I go back to A.html, ScrollView doesn't resize itself. (The scroll area is exceed the content of A.html) What I want to have, is dynamic change the scroll area of scroll view to fit the webview's content.

View 3 Replies View Related

Android :: ]Setting Button Height In XML Based On It's Width?

Oct 15, 2010

I am working on layout in android XML in which I would like to set a buttons height to match it's width when setup to fill parent. Obviously this number will change based on screen size, so I cannot use a set pixel size. Can someone help me with getting the button width based on screen size and then passing that to the height setting?

View 2 Replies View Related

Android :: Position Of Child View In Horizontal Scroll View

May 18, 2010

I have a HorizontalScrollView with a series of CompoundButtons. I want to find the (x,y) for a given child view. I have tried using:

getLocationOnScreen()
getLocalVisibleRect()
getChildVisibleRect()
like this:
View tmpView = this.findViewById(viewId);
Rect hitRect = new Rect();
tmpView.getLocalVisibleRect(hitRect);
the hitRect is always 0,0 - 0,0.

I need the x,y mainly to scroll to a particular child view. Any help is greatly appreciated.

View 1 Replies View Related

Android :: How To Change Height Of View

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

Android :: Height Of Custom View?

Oct 21, 2009

I have a custom class that extends view class. Now this custom view is set in the listadapter that extends baseadapter. Along with the custom view I have a TextView in the list.

So the xml i inflate for list view is

CODE:......

the customview sets a rounded rectangle behind the text in TextView. Now The height of the textview vary as per its content. So I want the height of the customview also vary as per the height of TextView.

View 2 Replies View Related

Android :: Header View Height In A ListView

Apr 7, 2010

Is it possible to control the height of a ListView's header view(s)? If I try containing my header view in a layout and set the height to say, 50 or 100, the height in the view seems to stay around 30.

View 2 Replies View Related

Android : Way To Get View / Layout Width / Height?

Aug 27, 2010

I'm an Android newbie. This should be the easiest thing in the world, but figuring it out is driving me batty: how do I get the dimensions of a view or layout?

View 2 Replies View Related

Android : Get A Custom View's Height And Width?

Nov 2, 2010

How do I use getMeasuredWidth() and getMeasuredHeight? It always returns 0. what is the difference between this and getHeight() and getWidth()?

View 3 Replies View Related

Android :: Increase Height Of Text View On Run Time

Aug 27, 2010

I have a TextView and I want to increase its height on runtime.I have used android:layout_height="wrap_content" but it did not gave me the desired result.I'm using a Relative Layout.i get text through edittext and i want to set it on textview.When i do this it shows only one line, and when i click on edittext it get expanded and full message is shown.

View 2 Replies View Related

Android :: Resize View Width And Height Dynamically?

Sep 17, 2010

I am adding two views to a linearlayout. When I click on the first view it has to occupy second views width also. How do I do that?

View 1 Replies View Related

Android :: View To Right Side Of Another And Centering Vertically On Second Views Height

Oct 18, 2010

I was wondering if there is a way for placing a view to the right side of another view and centering it vertically on the second views height. In know this can be done using a LinearLayout, but for other reasons the 2 views must be part of the same RelativeLayout.

View 1 Replies View Related

Android :: Webview Loaddata Scroll Setting Not Updating Till Clicked

Oct 17, 2010

I update the html in a webView using loadData() followed by a reload(). I get the new data to display but the scroll of the page has not updated.I want to keep the view of the page at the bottom. I can wait a long time and it still doesn't update.Once I click the webView the scroll bars adjust and I can drag to the bottom of the page and see the new text.Things I have tried:

- multiple settings and calls in onPageFinished(). None worked because the getContentHeight() hasn't changed yet.I have also tried to scrollTo(100 + getContentHeight) and that doesn't work.

- pageDown(true)

still no good, thinking i could simulate my click.adding a few br tags. This worked a bit, but the number of br's has to equal the number of lines of new text. Since the number of new lines is not something that can be exactly determined based on orientation and screen variables it's not a good fix.

View 1 Replies View Related

Android :: Create Animation List View From Top To Bottom With Increasing Height

Oct 25, 2010

Anyone has idea how to create animation from top to bottom for List View with increasing the height of each list item view ?

View 2 Replies View Related

Android :: Set Tab View To Scroll?

Mar 22, 2010

I have managed to set up a tabbed view for my app, and have the following xml for the UI

CODE:.........

yet am seemingly unable to scroll down to see the rest of the form (cuts off at one of the spinners, why is this?

View 2 Replies View Related

General :: How To Make Wallpaper Scroll In Apex Setting

Jan 7, 2013

How to make the wallpaper scroll in the apex setting.

View 1 Replies View Related

Android :: Add Scroll View For Particular Row In Runtime?

Aug 9, 2010

In my tableview i need to add the scroll view for the particular rows . Is there any way to create like this in android?

View 1 Replies View Related

Android :: View And ListView Scroll At Once?

Oct 22, 2009

What I have now is a layout that includes a list view at the bottom. All of the items in the layout above the list view remain fixed as you scroll through the list view. I would like the entire page to scroll so for example when you reached the bottom of the list you would no longer see the items above the list view.

View 5 Replies View Related

Android :: Scroll View Placement?

Sep 25, 2010

All I want to do is get the scroll view which contains a table to display below the text box. Right now, it displays over top of it. If I move the ScrollView below the RelativeLayout, then it doesn't show up at all! What do I need to do? I am really starting to think this whole layout idea is a bad one. Maybe I should just do it in code.

Here is my layout.

CODE:....................

View 3 Replies View Related

Android :: Add Scroll Bar In Grid View?

Sep 8, 2010

I want to add scroll bar in gridview,How can i add scroll bar in grid view?

View 2 Replies View Related

Android : Want To Scroll A Text View

May 28, 2009

I have a text view in the middle of a linear layout that I want vertical scrolling with I have set the flag for scrollbars vertical and it is showing up, but you can't actually scroll the text.

View 5 Replies View Related







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