[Android] scrollview match_parent not working
ScrollView 안에 있는 View에 match_parent를 줬는데도 높이가 변경이 되지 않는다.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|center_vertical"/>
</android.support.v4.widget.NestedScrollView>
위 소스를 보면 간단하다.
NestedScrollView 안에 TextView가 들어 있다.
layout_height 값이 match_parent로 되어 있지만, 아래와 같이 높이가 변경 되지 않았다.
이럴 경우 ScrollView에 속성 하나만 추가해주면 된다.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<TextView
android:id="@+id/tv_question"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|center_vertical" />
</android.support.v4.widget.NestedScrollView>
android:fillViewport="true"
위 속성만 추가 해주면 된다.
그럼 ScrollView 안에 있는 View를 Strech 해주는 역할을 합니다.
출처: https://stackoverflow.com/a/10211418
참고 하세요.