gpt4 book ai didi

android - 如何在android中调整Tabhost的高度

转载 作者:行者123 更新时间:2023-11-29 14:49:17 26 4
gpt4 key购买 nike

我想在 android 中调整 tabhost 的大小。我知道它已被弃用,但这对我来说是一个很好的选择,因为我正在使用带有自定义游标适配器的 ListActivity。如果 Fragment Tabhost 可能的话,我不会。

无论如何调整标签高度:

我尝试了以下方法:

for (int i = 0; i < tabHost.getTabWidget().getTabCount(); i++) 
{
tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 80;
}

它只在少数手机上有效。有没有其他方法可以解决这个问题?

谢谢!

最佳答案

现在,您正在以像素为单位进行设置,您应该使用 dp,

尝试替换

tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 80;

tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = (int) (80 * this.getResources().getDisplayMetrics().density);

关于android - 如何在android中调整Tabhost的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23884216/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com