对于我的应用程序,我使用的是手风琴布局,其中我有三个面板,并且我正在尝试将面板(texview)大小设置为适合设备高度的大小。当屏幕方向发生变化时,这不起作用。我的视图大小在横向时不会根据设备的高度而变化。请帮助我。
这是我的代码
if(layoutView.getId() == R.id.Advertitletext)
{
openLayout = panel1;
v = panel1.getVisibility();
hideThemAll();
if(v != View.VISIBLE)
{
panel1.setVisibility(View.VISIBLE);
params = advertoutput.getLayoutParams();
params.height = parentLinear.getHeight()-msgrecvtitle.getHeight()-msgsenttitle.getHeight()-mLogCheck.getHeight()-PearActivity.peartabs.getHeight();
advertoutput.setLayoutParams(params);
}
}
这是我的 onConfiguration() 方法
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ViewTreeObserver observer = parentLinear.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
parentLinear.getViewTreeObserver().removeGlobalOnLayoutListener(this);
if(openLayout==panel1){
params = advertoutput.getLayoutParams();
params.height = parentLinear.getHeight()-msgrecvtitle.getHeight()-msgsenttitle.getHeight()-mLogCheck.getHeight()-PearActivity.peartabs.getHeight();
advertoutput.setLayoutParams(params);
}
else if(openLayout == panel2){
params = msgrecvoutput.getLayoutParams();
params.height = parentLinear.getHeight()-adverttitle.getHeight()-msgsenttitle.getHeight()-mLogCheck.getHeight()-PearActivity.peartabs.getHeight();
msgrecvoutput.setLayoutParams(params);
}else if(openLayout == panel3){
params = msgsentoutput.getLayoutParams();
params.height = parentLinear.getHeight()-adverttitle.getHeight()-msgrecvtitle.getHeight()-mLogCheck.getHeight()-PearActivity.peartabs.getHeight();
msgsentoutput.setLayoutParams(params);
}
}
});
}