问题表明我知道我们无法覆盖Home键事件但是如果你看看android 2.2的模拟器,你会看到一个应用程序Car Home它已经覆盖了大多数键,如Home,end call.
现在,关键是他们是如何做到的?我试图窥视应用程序的源代码,但令我惊讶的是它不可用或我无法找到它,但我不认为以后是这种情况.
我正在按照ApiDemo示例在我的视图上设置动画(请参阅layout_grid_fade.html):
<?xml version="1.0" encoding="utf-8"?>
<gridLayoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:rowDelay="50%"
android:directionPriority="column"
android:animation="@anim/fade" />
Run Code Online (Sandbox Code Playgroud)
以下是我的代码
mView.startAnimation(AnimationUtils.loadAnimation(ViewModel.this, R.anim.layout_grid_fade));
mView.setImage(modelImages.get(0).image);
Run Code Online (Sandbox Code Playgroud)
但我得到例外不知道为什么?下面是我的日志跟踪
FATAL EXCEPTION: main
java.lang.RuntimeException: Unknown animation name: gridLayoutAnimation
at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:116)
at android.view.animation.AnimationUtils.createAnimationFromXml(AnimationUtils.java:83)
at android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:64)
at nick.kimK.ViewModel$1$1.run(ViewModel.java:72)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud) 我知道这些问题在SO上听起来很熟悉,但我有不同的问题,这就是我想要做的.
*编辑:*我能够完成第一和第二点,但不能完成第三点.
我搜索了很多,但没有找到解决方案,任何想法如何实现这一目标.
在删除操作栏选项卡之间的分隔符和填充时,我会遇到问题.我使用这个生成样式,以下是我的值-14条目,我在4以上的版本上测试
<style name="Theme.Example" parent="@style/Theme.Sherlock.Light.DarkActionBar">
<item name="android:actionBarItemBackground">@drawable/selectable_background_example</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Example</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Example</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Example</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Example</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_example</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_example</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Example</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">@style/Theme.Example.Widget</item>
</style>
// It seems below code has no effect
<style name="ActionBarTabStyle.Example" parent="Widget.Sherlock.ActionBar.TabBar">
<item name="android:showDividers">none</item>
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
<item name="android:minWidth">0dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
为了便于说明,这里的内容与我想要的完全相同,即选项卡和操作栏之间没有线条,几乎是0填充
