Android 是否为底部选项卡栏提供动态高度?
现在,我已经用固定的高度做了。这是我的密码 我想根据屏幕分辨率将此高度设置为动态高度Android 是否为底部选项卡栏提供动态高度?,android,xml,android-studio,tabbar,tabwidget,Android,Xml,Android Studio,Tabbar,Tabwidget,现在,我已经用固定的高度做了。这是我的密码 我想根据屏幕分辨率将此高度设置为动态高度 for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) { tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 130; if (i == 0) { tabHost.getTabWidget().getChildAt(i).s
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++)
{
tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 130;
if (i == 0)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#ffffff"));
}
else
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.WHITE);
}
}
for(int i=0;i
我找到了问题的解决方案
for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++)
{
// Log.e("Selcted : ", ""+i);
tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = getHeight(getApplicationContext());
if (i == 0)
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#ffffff"));
}
else
{
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.WHITE);
}
}
public int getHeight(Context context)
{
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0)
{
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}