在我的一项活动中,我有一个编辑框,当然点击时会打开键盘。但是,即使键盘有动画效果,编辑框似乎也会出现奇怪的延迟?香港专业教育学院尝试了一些不同的东西但无济于事。
以下是我的活动和xml文件。
活性
private TextView countText;
private ListView listView;
private ArrayList<MessagingObject> arrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_messaging_page);
overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
listView = (ListView) findViewById(R.id.messagingList);
counttext = (TextView) findViewById(R.id.characterCount);
counttext.setVisibility(View.GONE);
final Button sendMessage = (Button) findViewById(R.id.sendMessage_button);
EditText message = (EditText) findViewById(R.id.message_textbox);
Intent intent = getIntent();
String name = intent.getStringExtra("name");
message.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 20){
sendMessage.setVisibility(View.GONE);
counttext.setVisibility(View.VISIBLE);
String textOver = new String().valueOf(s.length() - 20);
counttext.setText("-"+textOver+"");
} else {
sendMessage.setVisibility(View.VISIBLE);
counttext.setVisibility(View.GONE);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
startTimer();
arrayList = new ArrayList<MessagingObject>();
getActionBar().setTitle(name);
}
XML文档
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f6f6f6">
<ListView
android:id="@+id/messagingList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/messageheaderbottom_layout"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:scrollbars="none"
android:divider="@android:color/transparent"
android:dividerHeight="30.0sp"
android:stackFromBottom="true"
android:background="#f6f6f6"
android:overScrollMode="never">
</ListView>
<RelativeLayout
android:id="@+id/messageheaderbottom_layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#DEDEDE">
<EditText
android:id="@+id/message_textbox"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:background="@drawable/textfield_rounded"
android:hint="Message"
android:textSize="15dp"
android:maxLength="140"/>
<Button
android:id="@+id/sendMessage_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/message_textbox"
android:layout_marginLeft="18dp"
android:layout_centerVertical="true"
android:text="Send"
android:textSize="18dp"
android:textColor="#344294"
android:background="@android:color/transparent"/>
<TextView
android:id="@+id/characterCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/message_textbox"
android:layout_marginTop="13dp"
android:layout_marginLeft="42dp"
android:textSize="18dp"
android:textColor="#000"/>
</RelativeLayout>
任何建议或解决方案都会很棒。谢谢。