2016-03-09 42 views
0

我有这样的布局:安卓:EditText上,滚动型不能正常工作

<ScrollView 
    android:id="@+id/scroll_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingTop="@dimen/keyline_1" 
     android:layout_above="@+id/action_bar_layout" 
     android:orientation="vertical"> 

    .... 

    <EditText 
      android:id="@+id/message" 
      style="@style/ItemNewsFeedMessage" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"    
      android:inputType="textMultiLine"/> 

</ScrollView 

我尝试这些解决方案:https://gist.github.com/laaptu/4cb395fded9a0700fcdb

不幸的行为尚未纠正:当我在进入新闻人物EditText结束时,主滚动不会在同一时间移动,所以我看不到最后一个字符集。

enter image description here

感谢您的帮助家伙!

+1

是否'ScrollView'只有一个孩子?在你的情况下,我想'LinearLayout'。在示例代码中看不到结束标记。 – jensbrulmans

+0

是的,只有一个孩子(LinearLayout) – anthony

回答

0

你提的问题不够清晰,可能是这可以解决您的问题

// set request Focus 

    mEditText.requestFocus(View.FOCUS_RIGHT); 

layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="@dimen/activity_vertical_margin" 
       android:paddingBottom="@dimen/activity_vertical_margin" 
       tools:context=".MainActivity"> 

    <ScrollView 
      android:id="@+id/scroll_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

     <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_above="@+id/action_bar_layout" 
       android:orientation="vertical"> 
     <EditText 
       android:id="@+id/message" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/lorem_ipsum" 
       android:textSize="22sp" 
       android:inputType="textMultiLine"/> 
     </LinearLayout> 

    </ScrollView> 

</RelativeLayout>