0
我有一个基本的TabActivity。在android 2.1上(可能还有旧版本),它看起来像在选项卡小部件下面添加了阴影。在2.3上,这个影子不存在。有没有办法将这个阴影彻底消失?也许像“android:fadingEdgeLength = 0”?TabHost - 摆脱阴影?
谢谢
我有一个基本的TabActivity。在android 2.1上(可能还有旧版本),它看起来像在选项卡小部件下面添加了阴影。在2.3上,这个影子不存在。有没有办法将这个阴影彻底消失?也许像“android:fadingEdgeLength = 0”?TabHost - 摆脱阴影?
谢谢
你说的是白色条纹吗?我砍死过去通过调用这个方法里面onTabChanged
让你的类实现OnTabChangeListener
private static TabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
// Instantiate your tab host normally
}
@Override
public void onTabChanged(String tabId) {
removeWhiteStrip(mTabHost);
}
/**
* Hack
* @param tabHost
*/
private static void removeWhiteStrip(TabHost tabHost) {
TabWidget tw = (TabWidget) tabHost.getChildAt(1);
Field mBottomLeftStrip;
Field mBottomRightStrip;
try {
mBottomLeftStrip = tw.getClass().getDeclaredField("mBottomLeftStrip");
mBottomRightStrip = tw.getClass().getDeclaredField("mBottomRightStrip");
if (!mBottomLeftStrip.isAccessible()) {
mBottomLeftStrip.setAccessible(true);
}
if (!mBottomRightStrip.isAccessible()) {
mBottomRightStrip.setAccessible(true);
}
// This is a blank drawable basically a 1x1 png with 100% alpha
mBottomLeftStrip.set(tw, MyApp.getInstance().getResources().getDrawable(R.drawable.blank));
mBottomRightStrip.set(tw, MyApp.getInstance().getResources().getDrawable(R.drawable.blank));
}
catch (java.lang.NoSuchFieldException e) {
// possibly 2.2
try {
Method stripEnabled = tw.getClass().getDeclaredMethod("setStripEnabled", boolean.class);
stripEnabled.invoke(tw, false);
}
catch (Exception e1) {
e1.printStackTrace();
}
}
catch (Exception e) {
// tut tut shouldn't catch generic exception and ignore it
// but we do because this is a hack
}
}
享受
嗨呀 - 我使用的是光的主题,让阴影我认为,看起来是黑色而不是白色。黑客不工作,阴影仍然显示。实际上只有在其中一个孩子是活动,而不是ListActivity时才显示,这很奇怪。 Argh,android ... – user291701 2011-02-11 21:55:21