【问题标题】:Android Tab icon image full sizeAndroid 选项卡图标图像全尺寸
【发布时间】:2011-08-10 03:00:43
【问题描述】:

我有一个带有 4 个选项卡的简单 tabController,但我希望图标图像占据整个选项卡。我还想要图标图像顶部的选项卡文本。我只需要一些提示就可以朝着正确的方向前进。

我无法发布我的标签的图片(没有足够的声望点)。但基本上我需要摆脱标签图标周围的所有填充。

我的图标是 png 文件。我的 tabControllerView 正在扩展 TabActivity,我正在使用 tab_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"    
android:id="@android:id/tabhost"    
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >
            <TabWidget
                android:id="@android:id/tabs"            
                android:layout_width="fill_parent"            
                android:layout_height="wrap_content" />
            <FrameLayout            
                android:id="@android:id/tabcontent"            
                android:layout_width="fill_parent"            
                android:layout_height="fill_parent"            
                />    
     </LinearLayout>
</TabHost>

对于每个选项卡,我在 tabControllerView 的 onCreate 中执行此操作:

spec = tabHost.newTabSpec("home").setIndicator("Home", 
res.getDrawable(R.drawable.ic_tab_home)).setContent(intent);
    tabHost.addTab(spec);

【问题讨论】:

    标签: android tabs icons size


    【解决方案1】:

    您应该可以通过以下方式做到这一点:

            for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++){
                tabHost.getTabWidget().getChildAt(i).setPadding(0,0,0,0);
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多