3
我在ScrollView
内有NestedScrollView
。 NestedScrollView
包含TextView
。所以当TextView
扩展到4或n lineas,我需要使它Scrollable TextView
。如何在Android中设置NestedScrollView的最大高度?
任何帮助非常感谢!
我在ScrollView
内有NestedScrollView
。 NestedScrollView
包含TextView
。所以当TextView
扩展到4或n lineas,我需要使它Scrollable TextView
。如何在Android中设置NestedScrollView的最大高度?
任何帮助非常感谢!
我希望你现在一定已经解决了这个问题。如果有人在将来寻找它,则不需要设置最大高度。只需将NestedScrollView的高度设置为37f,并且每当文本大小超过37时,NestedScrollView就会开始滚动。
XML:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</android.support.v4.widget.NestedScrollView>
或编程:
NestedScrollView nsv = new NestedScrollView(getActivity());
// Initialize Layout Parameters
RelativeLayout.LayoutParams nsvParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
// Set Layout Parameters
nsv.setLayoutParams(nsvParams);