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 d开发者_StackOverflow社区ifficult, 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.
精彩评论