0
HorizontalScrollView를 X 위치 또는 X 픽셀로 스크롤 할 수 없습니다. 그것은 단추가있는 선형 레이아웃을 가지고 있습니다.scrollTo, scrollBy로 스크롤하지 않는 선형 레이아웃이있는 HorizontalScrollView
<HorizontalScrollView
android:id="@+id/horizontal_room_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
android:scrollbars="none">
<LinearLayout
android:orientation="horizontal"
android:id="@+id/roomsBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- buttons -->
</LinearLayout>
</HorizontalScrollView>
자바 :
buttonList = (HorizontalScrollView) findViewById(R.id.horizontal_room_list);
//do stuff, at some point successfully save the scrolling offset with getScrollX()
barOffsetX = buttonList.getScrollX();
Log.e("x", "" + barOffsetX); //this prints a correct > 0 value
buttonList.scrollBy(barOffsetX, 0); //nothing happens, or
buttonList.scrollTo(barOffsetX, 0); //nothing happens
나는 문제가있는 LinearLayout에 대해있을 수 있습니다 생각합니다. 어떻게 스크롤 할 수 있습니까?
편집 : 프로그래밍 방식으로 새 단추를 추가하는 것이 문제라고 생각합니다.
슬프게도 scrollBy()에 어떤 값을 지정해도 scrollTo()는 아무 것도 변경하지 않습니다. 막대가 스크롤되지 않습니다. 매우 중요한 것을 언급하는 것을 잊어 버렸습니다 (제 질문을 편집했습니다). 문제는 버튼이 dinamically, java에서 추가된다는 것입니다. 이렇게하면 막대가 어떤 이유로 스크롤되지 않습니다. 잠시 동안 실제 눌려진 버튼에 초점을 맞춤으로써이 문제를 "해결"했지만,이 솔루션은 ConfigurationChange 이전과 똑같은 상태로 복원하고 싶기 때문에 마음에 들지 않습니다. 대답 주셔서 감사하지만 문제는 가치에 관한 것이 아닙니다. – user2502368