动作条搜索查看没有完全展开横向模式 [英] ActionBar SearchView not fully expanding in landscape mode
本文介绍了动作条搜索查看没有完全展开横向模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当使用操作栏搜索界面,所述插件扩展为占据在纵向模式的屏幕的整个宽度,但停止短的横向模式。
有没有一种方法来设置对搜索查看扩张布局PARAMS完全填补当用户键入搜索行动吧?
请参阅图像: http://i.imgur.com/3z8ZbJA.png
注:我不是目前使用的ActionBar福尔摩斯
编辑: 这是我做得到它的扩展全宽。
searchView.setOnSearchClickListener(新OnClickListener(){
私人布尔扩展=虚假的;
@覆盖
公共无效的onClick(视图v){
如果(!扩展){
扩展= TRUE;
的LayoutParams LP = v.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
}
}
});
解决方案
您是否尝试过类似的东西?
editView.setOnKeyListener(新OnKeyListener(){
私人布尔扩展=虚假的;
@覆盖
公共布尔onKey(视图V,INT关键code,KeyEvent的事件){
如果(扩展和放大器;!&安培; event.getAction()== KeyEvent.ACTION_DOWN){
扩展= TRUE;
的LayoutParams LP = v.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
}
返回false;
}
});
When using the action bar search interface, the widget expands to occupy the full width of the screen in portrait mode, but stops short in landscape mode.
Is there a way to set the expansion layout params on the SearchView to fully fill the action bar when the user is typing a search?
See image: http://i.imgur.com/3z8ZbJA.png
Note: I'm not currently using ActionBar Sherlock
Edit: Here's what I did to get it to extend the full width.
searchView.setOnSearchClickListener(new OnClickListener() {
private boolean extended = false;
@Override
public void onClick(View v) {
if (!extended) {
extended = true;
LayoutParams lp = v.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
}
}
});
解决方案
Did you try something like that?
editView.setOnKeyListener(new OnKeyListener() {
private boolean extended = false;
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (!extended && event.getAction() == KeyEvent.ACTION_DOWN) {
extended = true;
LayoutParams lp = v.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
}
return false;
}
});
这篇关于动作条搜索查看没有完全展开横向模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文