android - Switching ListViewes visibility causes scrolling issues -
i've tried set 2 listviewes @ 1 place, 1 of them visible @ time. (this set programmatically, setvisibility(view.gone)) after sec listview visible, , gone, first 1 not scrolling. i've made tests, , figured out, sec listview's onscrolllistener catches event. have thought how can set up, visible listview's onscrolllistener catches event? i've tried requestfocus(), didn't work.
here sinpets code:
public void toggle_services(view v) { if (home_services_detail.isshown()) { animationhelper.slide_up(this, home_services_detail); home_services_detail.setvisibility(view.gone); } else { home_services_detail.setvisibility(view.visible); animationhelper.slide_down(this, home_services_detail); home_services_detail.requestfocus(); } if (mobile_services_detail.isshown()) { animationhelper.slide_up(this, mobile_services_detail); mobile_services_detail.setvisibility(view.gone); } else { mobile_services_detail.setvisibility(view.visible); animationhelper.slide_down(this, mobile_services_detail); home_services_detail.requestfocus(); } }
and layout:
<linearlayout android:orientation="vertical" android:layout_width="775dp" android:layout_height="match_parent"> <!-- activity_info layout file --> <!-- clickable title --> <textview android:id="@+id/home_services_title" android:text="@string/home_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_vertical|center_horizontal" style="@style/theader"/> <!--content hide/show --> <linearlayout android:id="@+id/home_services_detail" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/homeserviceslist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> <textview android:id="@+id/mobile_services_title" android:text="@string/mobile_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" android:layout_weight="5.6" android:layout_gravity="bottom" style="@style/theader" android:gravity="center|center_vertical|center_horizontal" android:layout_height="fill_parent" android:maxheight="50dp"/> <!--content hide/show --> <linearlayout android:id="@+id/mobile_services_detail" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/mobile_fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/mobile_addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/mobileserviceslist" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> </linearlayout>
i managed solve problem. don't know why there unusual behaviour visibility altering, after made work around. in code, there visibility altering, removing layout parent should not on screen , add together layout should visible. both listviews works perfectly. think it's little bit slower visibility setting, it's working. necessary show on screen 2 title (mobile_services_title , home_services_title), that's reason set layout parameters programmatically.
the toggle function:
public void toggle_services(view v){ linearlayout.layoutparams bigwieght=new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.match_parent, 11f); linearlayout.layoutparams smallwieght=new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.match_parent, 1f); if(ishomevisible){ animationhelper.slide_up(this, home_services_detail); homeserviceslinearlayout.removeview(home_services_detail); homeserviceslinearlayout.setlayoutparams(bigwieght); mobileserviceslinearlayout.addview(mobile_services_detail); animationhelper.slide_down(this, mobile_services_detail); mobileserviceslinearlayout.setlayoutparams(smallwieght); } else { animationhelper.slide_up(this, mobile_services_detail); mobileserviceslinearlayout.removeview(mobile_services_detail); mobileserviceslinearlayout.setlayoutparams(bigwieght); homeserviceslinearlayout.addview(home_services_detail); animationhelper.slide_down(this, home_services_detail); homeserviceslinearlayout.setlayoutparams(smallwieght); } ishomevisible=!ishomevisible; }
and layout:
<linearlayout android:orientation="vertical" android:layout_width="775dp" android:layout_height="match_parent"> <!-- activity_info layout file --> <!-- clickable title --> <linearlayout android:id="@+id/homserviceslinearlayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <textview android:id="@+id/home_services_title" android:text="@string/home_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_vertical|center_horizontal" style="@style/theader"/> <!--content hide/show --> <linearlayout android:id="@+id/home_services_detail" android:layout_width="match_parent" android:layout_height="0dp" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/homeserviceslist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> </linearlayout> <linearlayout android:id="@+id/mobileserviceslinearlayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="9.5"> <textview android:id="@+id/mobile_services_title" android:text="@string/mobile_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" style="@style/theader" android:gravity="center|center_vertical|center_horizontal" android:layout_height="wrap_content" android:maxheight="50dp"/> <!--content hide/show --> <linearlayout android:id="@+id/mobile_services_detail" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/mobile_fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/mobile_addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/mobileserviceslist" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> </linearlayout> </linearlayout>
android listview scroll visibility
No comments:
Post a Comment