android - NestedScrollView is not scrolling due to Editext -
i facing issue when have following structure in nestedscrollview .
here xml file :
<android.support.v4.widget.nestedscrollview android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/app_base_color" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:id="@+id/nested_view_editprofile" android:focusable="true" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/app_base_color" android:weightsum="3"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <textview android:id="@+id/txtveditprofileusername" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:gravity="center" android:paddingbottom="10dp" android:paddingleft="3dp" android:paddingtop="10dp" android:textcolor="@color/orange" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.85" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingbottom="5dp" android:paddingtop="10dp" android:weightsum="2"> <textview android:id="@+id/txveditprofileentertainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.3" android:gravity="right" android:text="0" android:textcolor="@color/orange" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:paddingleft="3dp" android:singleline="true" android:text="entertainers" android:textcolor="@color/cement_grey" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingbottom="10dp" android:paddingtop="5dp" android:weightsum="2"> <textview android:id="@+id/txveditprofilespectator" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.3" android:gravity="right" android:text="0" android:textcolor="@color/orange" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:paddingleft="3dp" android:singleline="true" android:text="spectators" android:textcolor="@color/cement_grey" /> </linearlayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1.15" android:gravity="center" android:orientation="vertical"> <imagebutton android:id="@+id/imgbtneditprofilespactate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/transparent" android:paddingbottom="5dp" android:paddingtop="10dp" android:src="@drawable/plus" /> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.7" android:gravity="center" android:paddingbottom="10dp" android:paddingleft="3dp" android:text="spactate" android:textcolor="@color/orange" /> </linearlayout> </linearlayout> <textview android:id="@+id/txtvcom" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/app_base_color" android:padding="10dp" android:textcolor="@color/cement_grey" /> <textview android:layout_height="wrap_content" android:layout_width="match_parent" android:text="personal information" android:textcolor="@color/orange" android:background="@drawable/app_base_background"/> <com.customview.customeditext android:id="@+id/edtxedtprflname" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="name" android:textcolor="@color/cement_grey" android:inputtype="textimemultiline" android:drawableleft="@drawable/name" android:drawablepadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="true" android:focusableintouchmode="true" /> <com.customview.customeditext android:id="@+id/edtxedtprflusername" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="username" android:textcolor="@color/cement_grey" android:inputtype="textimemultiline" android:drawableleft="@drawable/username" android:drawablepadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="false" android:focusableintouchmode="true" /> <com.customview.customeditext android:id="@+id/edtxedtprflbio" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="bio" android:textcolor="@color/cement_grey" android:inputtype="textimemultiline" android:drawableleft="@drawable/bio" android:drawablepadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="true" android:focusableintouchmode="true" /> <com.customview.customeditext android:id="@+id/edtxedtprfldob" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="date of birth" android:textcolor="@color/cement_grey" android:inputtype="date|textimemultiline" android:drawableleft="@drawable/dob" android:drawablepadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:focusableintouchmode="true" android:enabled="true" /> <com.customview.customeditext android:id="@+id/edtxedtprflgender" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="gender" android:textcolor="@color/cement_grey" android:inputtype="textimemultiline" android:editable="false" android:drawableleft="@drawable/gender" android:drawablepadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="false" android:focusableintouchmode="true" /> <textview android:layout_height="wrap_content" android:layout_width="match_parent" android:text="private information" android:textcolor="@color/orange" android:background="@drawable/app_base_background"/> <com.customview.customeditext android:id="@+id/edtxedtprflemail" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="email" android:textcolor="@color/cement_grey" android:inputtype="textemailaddress|textimemultiline" android:drawableleft="@drawable/mail" android:drawablepadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="true" android:focusableintouchmode="true" /> <com.customview.customeditext android:id="@+id/edtxedtprflphone" android:layout_height="wrap_content" android:layout_width="match_parent" android:hint="phone" android:textcolor="@color/cement_grey" android:inputtype="phone|textimemultiline" android:maxlength="10" android:drawableleft="@drawable/phone" android:drawablepadding="10dp" android:background="@drawable/profile_pallets_boxes_background" android:enabled="false" android:focusableintouchmode="true" /> </linearlayout> </android.support.v4.widget.nestedscrollview>
now due editext unable scroll nestedscrollview use below solution , work fine prevent softkeyboard opening editext .
public class customeditext extends edittext { public customeditext(context _context){ super(_context); } public customeditext(context context, attributeset attrs){ super(context,attrs); } public customeditext(context context, attributeset attrs, int defstyleattr) { super(context, attrs, defstyleattr); } @override public boolean ontouchevent(motionevent event) { super.ontouchevent(event); return false; } }
i had similar issue. design support library great lib, it's bit buggy @ moment. can find issues regarding nestedscrollview here: nestedscrollview issues. have wait next updates until have working lib.
until then, can try alternative libs, such as: observablescrollview.
it pretty simple use:
1 - add dependency build.gradle file:
repositories { mavencentral() } dependencies { // other dependencies omitted compile 'com.github.ksoichiro:android-observablescrollview:1.5.0' }
2 - in layout, declare observablescrollview like:
<com.github.ksoichiro.android.observablescrollview.observablelistview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent" />
3 - in activity, implement observablescrollviewcallbacks:
public class mainactivity extends appcompatactivity implements observablescrollviewcallbacks {
4 - implement required methods , play them:
@override public void onscrollchanged(int scrolly, boolean firstscroll, boolean dragging) { } @override public void ondownmotionevent() { } @override public void onuporcancelmotionevent(scrollstate scrollstate) { }
5 - example on showing/hiding actionbar on scrolling list:
@override public void onuporcancelmotionevent(scrollstate scrollstate) { actionbar ab = getsupportactionbar(); if (scrollstate == scrollstate.up) { if (ab.isshowing()) { ab.hide(); } } else if (scrollstate == scrollstate.down) { if (!ab.isshowing()) { ab.show(); } } }
hope helps.
Comments
Post a Comment