我有一个基本的TabActivity。在Android 2.1(可能还有旧版本)上,它看起来像是在标签小部件下面添加了一个投影。在2.3,这个阴影不存在。有没有办法彻底扭转阴影?也许像“android:fadingEdgeLength = 0”?
由于
答案 0 :(得分:1)
你在谈论白条吗?我通过在 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
}
}
享受