我正在尝试向LinearLayout的背景添加渐变,它给了我一个ClassNotFoundException。
这是布局: RES /抽拉/ blue_gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:startColor="#003399"
android:endColor="#002288"
android:angle="270"
/>
</shape>
RES /布局/ main.xml中
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/blue_gradient"
android:orientation="horizontal"
android:layout_gravity="right" >
以下是例外:
03-31 23:21:14.534: E/AndroidRuntime(1594): FATAL EXCEPTION: main
03-31 23:21:14.534: E/AndroidRuntime(1594): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kizbit.pairfinder/com.kizbit.pairfinder.Main}: android.view.InflateException: Binary XML file line #2: Error inflating class shape
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.os.Looper.loop(Looper.java:123)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-31 23:21:14.534: E/AndroidRuntime(1594): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 23:21:14.534: E/AndroidRuntime(1594): at java.lang.reflect.Method.invoke(Method.java:507)
03-31 23:21:14.534: E/AndroidRuntime(1594): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-31 23:21:14.534: E/AndroidRuntime(1594): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-31 23:21:14.534: E/AndroidRuntime(1594): at dalvik.system.NativeStart.main(Native Method)
03-31 23:21:14.534: E/AndroidRuntime(1594): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class shape
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-31 23:21:14.534: E/AndroidRuntime(1594): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.Activity.setContentView(Activity.java:1657)
03-31 23:21:14.534: E/AndroidRuntime(1594): at com.kizbit.pairfinder.Main.onCreate(Main.java:38)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-31 23:21:14.534: E/AndroidRuntime(1594): ... 11 more
03-31 23:21:14.534: E/AndroidRuntime(1594): Caused by: java.lang.ClassNotFoundException: android.view.shape in loader dalvik.system.PathClassLoader[/data/app/com.kizbit.pairfinder-1.apk]
03-31 23:21:14.534: E/AndroidRuntime(1594): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-31 23:21:14.534: E/AndroidRuntime(1594): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-31 23:21:14.534: E/AndroidRuntime(1594): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
03-31 23:21:14.534: E/AndroidRuntime(1594): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
03-31 23:21:14.534: E/AndroidRuntime(1594): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
03-31 23:21:14.534: E/AndroidRuntime(1594): ... 19 more
答案 0 :(得分:0)
ant clean
修复了它!
糟糕!无法提交您的答案,因为:
正文必须至少30个字符;你进入了21