0
하나의 하위 레이아웃 (선형 레이아웃)을 포함하는 스크롤보기가 있고 그 자식은 상대 레이아웃과 선형 레이아웃을 포함합니다. 상대 레이아웃과 선형 레이아웃은 화면 절반을 공유합니다. 선형 레이아웃에는 동적으로 단추가 추가되었습니다.ScrollView가 오버플로 된 레이아웃을 스크롤하지 않습니다.
이제 상대적인 레이아웃과 선형 레이아웃을 스크롤하는 동안 스크롤 뷰는 스크롤하지 않기 때문에 문제가 발생합니다.
<ScrollView>
<LinearLayout>
<RelativeLayout>
</RelativeLayout>
<LinearLayout>
->Dynamically adding buttons here
</LinearLayout>
</LinearLayout>
</ScrollView>
내가 그 버튼이있는 ScrollView로 이동합니다
참고로 내 XML 코드는 다음과 같습니다 -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/whitecolor"
android:orientation="vertical"
>
<ScrollView
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RelativeLayout
android:
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bluecolor"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/stauslinearlayout"
android:layout_marginBottom="8dp"
android:padding="5dp"
android:gravity="center"
android:textColor="@color/whitecolor"
android:text="@string/app_name"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="@color/bluecolor"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/edit_text_custom"
android:singleLine="true"
android:hint="@string/status"
android:textColor="#000"
android:textColorHint="#5222"
android:padding="7dp"
android:maxLength="50"
android:cursorVisible="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:drawableLeft="@android:drawable/ic_input_add"
android:ems="10"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|center_horizontal"
android:gravity="center"
android:layout_weight="0"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:padding="5dp"
android:text="@string/statusnumber"
android:background="@drawable/edit_text_custom"
/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/whitecolor"
android:text="abcdfrg"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
두 자식 레이아웃 모두 단일 스크롤보기로 스크롤하기를 원하기 때문에 첫 번째 방법을 사용할 수 없습니다. 두 번째 방법은 내 문제와 같은 행동을하는 동안. 그러나 동적으로 첫 번째 자식 높이를 화면 높이/2로 설정 한 다음 동적으로 스크롤 뷰에 단추를 추가하여이 작업을 수행했습니다. 고마워요! – Aviverma
@Aviverma, 오신 것을 환영합니다. – Rumit