请问怎么将每一个选项卡所设置的图片自动适应填充到所在的选项卡中,图中的icon显得很小很孤立,能不能让它填满,在线等

解决方案 »

  1.   

    自定义Indicator 
    public void setIndicater(TabSpec body, String title, Drawable icon,TabWidget tabWidget, Context context)
    {
    RelativeLayout tabIndicator1 = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.indicater, tabWidget,false);  
    TextView textView = (TextView)tabIndicator1.getChildAt(1);  
    textView.setText(title);
    ImageView imageView = (ImageView)tabIndicator1.getChildAt(0);  
    imageView.setImageDrawable(icon);
    body.setIndicator(tabIndicator1);
    }
      

  2.   

    请问下2楼,自定义的这个setIndicater方法,是直接放在创建TabHost的Activity中吗tabHost.addTab(tabHost.newTabSpec("").setIndicator("",getResources().getDrawable(R.drawable.chinese_food)).setContent(R.id.linerlayout2));这是我添加tab的语句,是不是要把这其中setIndicator("",getResources().getDrawable(R.drawable.chinese_food))用自定义的setIndicater方法替代呢
      

  3.   

    tabSpec = tabHost.newTabSpec(getString(R.string.FE_LOCAL_FILES));
    setIndicater(tabSpec, getString(R.string.local),
    getResources().getDrawable(R.drawable.filebrowser_local_icon),tabWidget, this);
    intent = new Intent(..........);
    intent.putExtra("KEY_FILE_TYPE", fileType);
    tabSpec.setContent(intent);
    tabHost.addTab(tabSpec);