Android 视图';s alpha始终是0还是1

Android 视图';s alpha始终是0还是1,android,android-linearlayout,android-view,alpha,Android,Android Linearlayout,Android View,Alpha,我在滚动视图中有一个线性布局。某些视图将添加到线性布局中。在ScrollView上,会附加一个scrollListener,并在滚动时更改LinearLayout的alpha。问题是,在向LinearLayout添加8个视图之前,它会按预期工作,而卷轴上的淡入效果与我希望的完全一样。但添加到LinearLayout的9个或更多视图及其alpha将成为一个触发器,当其alpha为1时变为可见,而在1和0之间变为不可见。以下是我的布局: <ScrollView xmlns:android="h

我在滚动视图中有一个线性布局。某些视图将添加到线性布局中。在ScrollView上,会附加一个scrollListener,并在滚动时更改LinearLayout的alpha。问题是,在向LinearLayout添加8个视图之前,它会按预期工作,而卷轴上的淡入效果与我希望的完全一样。但添加到LinearLayout的9个或更多视图及其alpha将成为一个触发器,当其alpha为1时变为可见,而在1和0之间变为不可见。以下是我的布局:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/scroll_view"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout
            android:alpha="0"
            android:paddingLeft="16dp"
            android:paddingRight="16dp"
            android:animateLayoutChanges="true"
            android:orientation="vertical"
            android:id="@+id/news_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
</ScrollView>
滚动和alpha值是预期值。另外,正如我前面所说,在LinearLayout中有8个项目之前,它可以正常工作。如有任何帮助/线索,将不胜感激

if (scrollView.getViewTreeObserver().isAlive())
        scrollView.getViewTreeObserver().addOnScrollChangedListener(
                new ViewTreeObserver.OnScrollChangedListener() {
                    @Override
                    public void onScrollChanged() {
                        final int scrollY = scrollView.getScrollY();
                        final float alpha = (1.0f / newsTitle.getY()) * scrollY;

                        newsLayout.setAlpha(alpha > 1 ? 1 : alpha);
                        arrow.setAlpha(1 - alpha);
                        Log.e(TAG, "scrollY: " + scrollY + " alpha: " + alpha);
                    }
                });
}