我正在尝试更改我的搜索栏的宽度,以便当用户开始输入搜索栏时会覆盖收藏按钮,但当他们不输入收藏按钮时会显示。
这是我现在拥有的
searchBar.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable arg0){
menuItems.this.adapter.getFilter().filter(arg0);
if(searchBar.getText().length() <= 0){
searchBar.getLayoutParams().width = 280;
favButton.getLayoutParams().width = 15;
}
else{
searchBar.getLayoutParams().width = 295;
favButton.getLayoutParams().width = 0;
}
}
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});