2014-02-14 12 views

Antwort

9

kann 100%

<EditText 
    android:inputType="textMultiLine" 
    android:lines="int number" <!-- Total Lines prior display --> 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:scrollbars="vertical"/> 
0

Haben Sie versucht mit? :

<EditText 
      android:id="@+id/edt_note" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:ems="10" 
      android:maxLines="3" 
      > 
9

Verwenden inputType="textMultiLine" und setzen android:lines="3" wie:

<EditText 
android:inputType="textMultiLine" 
android:lines="3" <!-- Total Lines prior display --> 
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:scrollbars="vertical" 
/> 
2

In Ihrem Text bearbeiten fügen Sie einfach

android:inputType="textMultiLine" 
    android:maxLines="3"> 
0

Dieser Code-Schnipsel Nehmen ... Sie Ihre Anforderung Recht bekommen. Und eine Sache zu beachten, müssen Sie hart codierte Höhe von ScrollView geben ... Ich gebe hier als 70dip.

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="70dip" > 

    <EditText 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:singleLine="false" /> 
</ScrollView> 
0

funktionieren, wenn Textview Linien zweizeilige Scroll überschreitet

if (mTvContacts.getLayout().getLineCount() >= 2) { 
    if (scrollContactsHeight == 0) 
     scrollContactsHeight = scrollContacts.getHeight(); 

     scrollContacts.getLayoutParams().height = scrollContactsHeight * 2; 
} else { 
    if (scrollContactsHeight == 0) 
     scrollContacts.getLayoutParams().height = scrollContacts.getHeight(); 
    else 
     scrollContacts.getLayoutParams().height = scrollContacts.getHeight()/2; 
} 


<ScrollView 
     android:id="@+id/scrollContacts" 
     android:layout_width="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_height="wrap_content"  
     android:layout_marginLeft="5dp"   
     android:layout_marginRight="5dp"   
     android:layout_toRightOf="@+id/tvTo" 
     android:layout_centerVertical="true" 
     android:layout_toLeftOf="@+id/imgAddContacts"> 

     <TextView 
      android:id="@+id/tvContacts" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"  
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="wfd" 
      android:textColor="#000" /> 

</ScrollView> 
0

scrollt ich glaube, diese Frage mehr über das Hinzufügen von mehrzeilige editText innerhalb Scrollview ist.

Innenscroll, Wenn Ihr EditText mehr Text hat man nicht in der Lage sein, nach innen zu bewegen, und nicht ganze Seite scrollt.

Sie können dies mit Hilfe von Touch erreichen.

edtDescription = (EditText)findViewById(R.id.edt_description); 

    edtDescription.setVerticalScrollBarEnabled(true); 
    edtDescription.setOverScrollMode(View.OVER_SCROLL_ALWAYS); 
    edtDescription.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); 
    edtDescription.setMovementMethod(ScrollingMovementMethod.getInstance()); 

    edtDescription.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View view, MotionEvent motionEvent) { 

      view.getParent().requestDisallowInterceptTouchEvent(true); 
      if ((motionEvent.getAction() & MotionEvent.ACTION_UP) != 0 && (motionEvent.getActionMasked() & MotionEvent.ACTION_UP) != 0) 
      { 
       view.getParent().requestDisallowInterceptTouchEvent(false); 
      } 
      return false; 
     } 
    }); 
Verwandte Themen