为什么寻呼机中的scrollview不能在Android 4.1.2 API 16中滚动,而可以在其余部分工作?

为什么寻呼机中的scrollview不能在Android 4.1.2 API 16中滚动,而可以在其余部分工作?,android,android-viewpager,scrollview,Android,Android Viewpager,Scrollview,我有一个ScrollView和一个TextView在ViewPager中滚动文本。我的应用程序支持最低API 8。在我使用Android 4.1.2 API 16在三星Galaxy S2上进行测试之前,一切正常。滚动视图中的文本不会滚动。当我用谷歌搜索它时,一个建议是Swype键盘,但当我在Android 4.1.2股票模拟器上运行它时,问题仍然存在。然后我试着检查它是否在不同的API上工作,我已经检查过,它在这些API上工作:10、13、15、17和19。它在API=17时滚动缓慢。它滚动正常

我有一个
ScrollView
和一个
TextView
ViewPager
中滚动文本。我的应用程序支持最低API 8。在我使用Android 4.1.2 API 16在三星Galaxy S2上进行测试之前,一切正常。
滚动视图中的文本不会滚动。当我用谷歌搜索它时,一个建议是Swype键盘,但当我在Android 4.1.2股票模拟器上运行它时,问题仍然存在。然后我试着检查它是否在不同的API上工作,我已经检查过,它在这些API上工作:10、13、15、17和19。它在API=17时滚动缓慢。它滚动正常(缓慢和快速)

为什么除了16之外,其他所有API都可以使用

这是我的
ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater
            .inflate(R.layout.fragment_screen_slide_page, container, false);

    // Set the title view to show the page number.
    ((TextView) rootView.findViewById(android.R.id.text1)).setText(
            getString(R.string.title_template_step) + (mPageNumber + 1));

    // Set background image and text (mPageNumber start with 0)
    switch (mPageNumber + 1) {
        case 1:
            rootView.findViewById(R.id.scroll_view_slides).setBackgroundResource(R.drawable.background_1);
            ((TextView) rootView.findViewById(R.id.textScroll)).setText(getString(R.string.page1));
            break;
        case 2:
            rootView.findViewById(R.id.scroll_view_slides).setBackgroundResource(R.drawable.background_2);
            ((TextView) rootView.findViewById(R.id.textScroll)).setText(getString(R.string.page2));
            break;
        case 3:
            rootView.findViewById(R.id.scroll_view_slides).setBackgroundResource(R.drawable.background_3);
            ((TextView) rootView.findViewById(R.id.textScroll)).setText(getString(R.string.page3));
            break;
        case 4:
            rootView.findViewById(R.id.scroll_view_slides).setBackgroundResource(R.drawable.background_4);
            ((TextView) rootView.findViewById(R.id.textScroll)).setText(getString(R.string.page4));
            break;
    }
    return rootView;
}
这是这个片段的.xml文件

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll_view_slides"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<!-- content. -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp">

    <!-- This is the text which are scrolled -->
    <ScrollView
        android:id="@+id/scrollViewText"
        android:layout_width="280dp"
        android:layout_height="100dp"
        android:fadeScrollbars="false"
        android:background="@android:color/transparent"
        android:fillViewport="true"
        android:focusable="true"
        android:layout_gravity="right">

        <TextView style="?android:textAppearanceLarge"
            android:id="@+id/textScroll"
            android:lineSpacingMultiplier="1.1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="14dp"
            android:textColor="@color/day"
            android:text="@string/lorem_ipsum" />


    </ScrollView>

    <!-- This text shows the page number -->
    <TextView android:id="@android:id/text1"
        style="?android:textAppearanceLarge"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp" />

</FrameLayout>


尝试滚动
滚动视图
而不是
文本视图
,如:

ScrollView.fullScroll(ScrollView.FOCUS_DOWN);

另外,将XML布局更改为:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp">
    <!-- This is the text which are scrolled -->
    <ScrollView
        android:id="@+id/scrollViewText"
        android:layout_width="280dp"
        android:layout_height="100dp"
        android:fadeScrollbars="false"
        android:background="@android:color/transparent"
        android:fillViewport="true">
        <TextView
            style="?android:textAppearanceLarge"
            android:id="@+id/textScroll"
            android:lineSpacingMultiplier="1.1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="14dp"
            android:textColor="@color/day"
            android:text="@string/lorem_ipsum" />
    </ScrollView>
    <!-- This text shows the page number -->
    <TextView android:id="@android:id/text1"
        style="?android:textAppearanceLarge"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp" />
</FrameLayout>

注意:我已经删除了最外层的
滚动视图
,除非还有更多的代码没有发布。否则,最外层的滚动视图是多余的。而且,如果它仍然不起作用,则从
滚动视图中删除
android:fillViewport=“true”

建议:除非您真的需要,否则我会使用
相对布局
线性布局
,而不是
框架布局


重要信息:不能在一个布局中同时使用两个
滚动视图
,它不能跨所有API级别工作。

如果我不够清楚,很抱歉。我可以发布除API 16之外的所有API的工作代码。如果
TextView
包含/嵌入在
ScrollView
中,则使用我上面的方法滚动
TextView
。否则,请编辑您的帖子以包含XML代码,这样我就可以看到您是如何构建
TextView
ScrollView
的。另外,当你说“适用于除16以外的所有API”时,你是否在不同制造商和/或安卓AVD的不同安卓设备上测试过?我在HTC上测试过安卓3.1、华硕安卓4.4、华硕安卓4.2、三星安卓4.1.2(不工作)、安卓10、15、16(不工作)、17、,19.@espy:修改了我的答案,以包含您发布的XML布局的修改版本。最外层的
ScrollView
ViewPager
使用,如我使用的示例所示。那么问题是,
ViewPager
是否需要
ScrollView
或者我可以使用
RelativeLayout
来代替?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp">
    <!-- This is the text which are scrolled -->
    <ScrollView
        android:id="@+id/scrollViewText"
        android:layout_width="280dp"
        android:layout_height="100dp"
        android:fadeScrollbars="false"
        android:background="@android:color/transparent"
        android:fillViewport="true">
        <TextView
            style="?android:textAppearanceLarge"
            android:id="@+id/textScroll"
            android:lineSpacingMultiplier="1.1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="14dp"
            android:textColor="@color/day"
            android:text="@string/lorem_ipsum" />
    </ScrollView>
    <!-- This text shows the page number -->
    <TextView android:id="@android:id/text1"
        style="?android:textAppearanceLarge"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp" />
</FrameLayout>