Android ScrollView无法调整为新的EditText内容

时间:2017-10-09 15:36:03

标签: android

EditText中包含的ScrollView中包含LinearLayout

public class ScrollingTextView extends LinearLayout {

  public ScrollingTextView(Context context) {

      super(context);

      scrollView = new ScrollView(context);
      scrollView.setFillViewport(true);
      scrollView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

      editText = new EditText(context);
      editText.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
      editText.setGravity(Gravity.BOTTOM);

      scrollView.addView(editText);
      this.addView(scrollView);
    }
}

我的Manifest中也有这个:

android:windowSoftInputMode="adjustResize"

问题是,当我在EditText中输入新内容时,ScrollView大小未调整。当我尝试物理滚动时,ScrollView不允许我滚动额外的内容。

似乎EditText高度变得大于ScrollView高度。

有关如何强制ScrollViewEditText身高相匹配的任何想法?

0 个答案:

没有答案