FrameLayout.LayoutParams params=
new FrameLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout searchViewContainer =
(LinearLayout)searchView.findViewById(R.id.search_view_container);
params =
(FrameLayout.LayoutParams)searchViewContainer.getLayoutParams();
params.setMargins(0, 80, 0, 0);//left,top,right,bottom
searchViewContainer.setLayoutParams(params);
使用getLayoutParams()时,必须要有父控件。
网友评论