2017-07-27 213 views

回答

1

我希望你現在一定已經解決了這個問題。如果有人在將來尋找它,則不需要設置最大高度。只需將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); 
相關問題