【发布时间】:2011-04-26 15:37:12
【问题描述】:
大家好 我正在尝试编写一个选项卡活动,其中每个选项卡都有一个用于指标的自定义视图。 视图像这样膨胀:
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
specIndicatorView = inflater.inflate(R.layout.tab_indicator, null);
indicatorIv = (ImageView)specIndicatorView.findViewById(R.id.indicatorImage);
indicatorTv = (TextView)specIndicatorView.findViewById(R.id.indicatorText);
indicatorIv.setImageDrawable(context.getResources().getDrawable(indicatorImageRes));
indicatorTv.setText(indicatorTextRes);
问题是子视图中定义的布局参数不影响它,那是因为我不知道如何将父视图传递给inflate方法。
我要做的只是有一个图像和一些文本,其中图像与顶部对齐,文本与指示器视图的底部对齐,但我还需要一些小调整,需要我使用它指标策略。 看了整个tab机制的源码,不知道怎么获取父视图,你知道怎么做吗? 你有更好的方法来实现我的需要吗?
谢谢
【问题讨论】:
标签: android tabs android-tabhost tabwidget