TabHost inside of a Scrollview: always scrolls down when a Tab is clicked

I have an Activity which has a Scrollview as the top level element. Inside there are some other Views and at some point there is a TabHost. You might get a better impression by looking at the screenshot. The TabHost has three tabs, each with another Activity that are launched by an Intent.

Everything is working fine except one thing. Whenever I click on a Tab, the Scrollview automatically scrolls down as you can see over here. The TabHost is out of the screen afterwards. I simply don't want it to scroll down, but can't see what the problem is. I tested on a 1.5 and 1.6 device and a 2.0 Emulator with the same results.

The xml of my TabHost looks like this:

                android:layout_height="wrap_content" />

And this is the code for adding a Tab:

private void addTab(int descriptionRes, Class<?> destination, int flags) {
    String description = getString(descriptionRes);
    TabSpec spec = mTabHost.newTabSpec(description);
    Intent i = new Intent(this, destination);

Any suggestions?

Asked by: Aida417 | Posted: 20-01-2022

Answer 1

You could try setting the Activity inside the TabHost as scrollable, rather than the top-level Activity itself.

Answered by: Rafael243 | Posted: 21-02-2022

Similar questions

java - Android Scrollview: How to select the Scrollview to return to?

I'm working on an android app that's working with Scrollviews. On each scrollview are two buttons, info and gallery. When the gallery button is clicked it takes you to a gallery xml. When the info button is clicked it takes you back to the info page. The problem is, when the info button is clicked it brings you back to the info page on the first scrollview, even if you are on the third or fourth scrollview.

java - ScrollView: Pass touch events to children

I made a "joystick" out of an ImageView. It is inside a ScrollView. It works without the ScrollView but inside the ScrollView it does not receive TouchEvents for vertical movement. How can I stop the ScrollView from blocking the touch event?

android - Pinch zooming with ScrollView: Updating its scrolling behaivor when child size changes

I have a custom class which I extended from the ScrollView. What I want to do is to implement pinch zooming with this class, with which I want to zoom to the ScrollView's child and scroll the zoomed content as needed. Basically, I want the same behavior which the UIScrollView class of iOS has (it is a SHAME that Android does not provide any built-in zooming f...

android - WebView in ScrollView: "View too large to fit into drawing cache" - how to rework layout?

I have a layout with a ScrollView, which contains the following views: ImageView, TextView, WebView, TextView. (This is because I would like to scroll the whole together, not just the contents of the WebView) After loading some HTML in the WebView, I receive the following: WARN/View(632): View too large to fit...

android - ScrollView: set some sliding "threshold" before actually scrolling ScrollView

Here's the idea: I have some ScrollView, e.g. with 10 elements, say buttons. Only 5 are visible at the time. By default, if I swipe up a little bit (30% of next element's height), app will show me 30% of 6th item, and hide 30% of 1st item at the top. I would like to customize this behavior, so that it pulls up a new element from below only after I've swiped up for more than a half of that elements height.

Android ScrollView: Scrolling out of display

I have a HorizontalScrollView which contains a TextView with a long text. The ScrollView is scrolled programmatically from right to left to the end of the TextView's text so that the end is displayed at the right edge of the phones display. Is it possible to scroll the text even further so that it scrolls out of the left side of the phones display?

android - ScrollView: Button is not visible completely

I have a Problem with one activity xml in my Android project. Its a ScrollView and inside i have a LinearLayout. In the LinearLayout i added a Button. But the button is not completely visible. Only 2px or like that. &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="" android:layout_width="match_parent" android:layout_height="match...

java - Android Scrollview: " On scroll jump in fixed intervals"

I desire to have a scroll effect in my android app that jumps in certain intervals on scroll. For an example then what i want to achieve is when the user scrolls then it will scroll in intervals of 100dp in the direction the user scrolls. Take a look at this picture:

android - Layout with scrollview: how to reach the bottom as fast as possible?

I have a minor problem which i can't solve. I have a layout with scrollview embedding a lot of views. Everything work fine with the android studio preview in design mode but when i want to access to a view at the bottom, i have to scroll the mouse wheel very long time in order to reach the bottom of the layout. So it works but as soon as i make a change of the view located at the bottom i have to scroll the mouse wheel ve...

Android ScrollView: Bottom Button not showing

The problem is I want to make my registration activity scrollable, but whenever I launch the app,I can scroll but I cannot view the button below. I have tried putting alignParentTop = true and it focuses on the first edittext. Here is my code: &lt;LinearLayout&gt; &lt;ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;LinearL...

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android