简体   繁体   中英

TextView scrolling

I'm displaying a photo with a small scrollable TextView below it. On HTC Wildfire when I tap on the text and drag my finger across the screen, even outside the TextView, the text scrolls as it's supposed to. (Likewise, the default system 'all applications' screen also scrolls even if you drag your finger to the status bar.)

However, on HTC Desire when I drag my finger outside the TextView, the scrolling suddenly stops. This makes scrolling really difficult, because the TextView itself is relatively small.

How do I make the text scroll in the TextView even when the user drags his finger outside the TextView area?

This is my source:

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
>
<TextView 
    android:id="@+id/captionbox" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent"
    android:padding="3dp"
    android:maxLines="6"
    android:background="@color/translucent"

    android:scrollbars="vertical"
    android:scrollbarStyle="insideInset"
    android:layout_gravity="bottom"
    android:saveEnabled="true"
    android:text="@string/captiontest"
/>
</ScrollView>

In code, I call this method

private void displayCaptionBox() {
    TextView captionBox = (TextView) findViewById(R.id.captionbox);
    captionBox.setMovementMethod(new ScrollingMovementMethod());
}

The solution is remove the <ScrollView> element. No idea why, but apparently Desire has a bug when a TextView is set to scrollable and is within a ScrollView at the same time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM