Android fixed background image in scrollview while scrolling -
i have situation need scrollview have background image shouldn't scroll along it's parent when moving. before of suggest me links setting background image , that, have tried , it's not working.
the whole story goes like: have activity fragments have own backgrounds input fields. when focusing on input fields, keyboard appears , background image squeezes. put image on background of scrollview fixed issue of squeezing background raised concern background image should stay static while scrolling parent scrollview.
the second solution of may suggest setting background of activity rather playing scrollview. that's right, had make style element background of theme appears odd while transitioning different fragments plus adds overhead when have lot of code , fragments move forward , back.
that's point stuck. have gone through links below, if need know tried or not.
below layout using fragments (it's being done programmatically)
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/top_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <scrollview android:id="@+id/scrollview1" android:layout_width="match_parent" android:layout_height="match_parent" android:fillviewport="true" android:scrollbars="none" > <framelayout android:layout_width="match_parent" android:layout_height="wrap_content" > <imageview android:id="@+id/backgroundview" android:layout_width="match_parent" android:layout_height="match_parent" android:contentdescription="@string/app_name" android:scaletype="fitxy" /> <linearlayout android:id="@+id/parent_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > </linearlayout> </framelayout> </scrollview> </linearlayout>
so if guys have better solution keeping in mind situation have, warmly welcomed. thank
none of above works me reason things works.
getwindow().setbackgrounddrawableresource(r.mipmap.img_reg_bg);
put in oncreate method hope help.
Comments
Post a Comment