我在EditText
内的RelativeLayout
(在下面的代码中命名为TopLayout
)内有一个ListView
。 EditText
上有TextWatcher,它可以更改RelativeLayout
(和ListView
)的高度。但是,当高度发生变化时,EditText
内的光标会移到开头。
反正有没有办法让它保持原样?
public void setItemHeight(int itemPos, int itemHeight) {
if (mChallengingThoughtsListView != null) {
View itemView = mChallengingThoughtsListView.getChildAt(itemPos);
LinearLayout topLayout = itemView.findViewById(R.id.TopLayout);
// Set item height
ViewGroup.LayoutParams params = topLayout.getLayoutParams();
params.height = itemHeight;
topLayout.setLayoutParams(params);
// TODO: Put code to place cursor back where it was
}
}