android - How to disable scrolling in HorizontalScrollView? -


what want in pictures: enter image description here

on words: want disable scrolling formatting text inside horizontalscrollview.

part of xml:

<scrollview     android:id="@+id/review_scrollview"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:scrollbars="horizontal"     android:fillviewport="true"     android:layout_margintop="10dp">      <horizontalscrollview xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="fill_parent"         android:layout_height="wrap_content">           <textview             android:id="@+id/tt_review_content"             android:layout_width="wrap_content"             android:layout_height="fill_parent"             android:textappearance="?android:attr/textappearancesmall"             android:text="some long text"             android:scrollhorizontally="true"/>      </horizontalscrollview>  </scrollview> 

method(doesn't works):

private void setttareawrapcontent(boolean value) {     viewgroup.layoutparams params = textfield.getlayoutparams();     if(value) { // wrap content         textfield.setwidth(scrollview.getwidth());     } else { // scroll         params.width = viewgroup.layoutparams.wrap_content;     }     textfield.setlayoutparams(params); } 

there simple way this.

check if user wants scroll or not , store in boolean variable, shouldscroll.

now in oncreate,

horziontalscrollview scrollview= (horizontalscrollview)findviewbyid(r.id.scrollview);  if(!shouldscroll) scrollview.setontouchlistener(new ontouch()); 

you need define class ontouch extending ontouchlistener

private class ontouch implements ontouchlistener {     @override     public boolean ontouch(view v, motionevent event) {     return true;     } } 

now textview formatting, use android:singleline="false" or use android:width="0dip"


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -