0

我在 XML 中遇到错误,它说在 android 包中找不到属性 centercolor、endcolor 起始颜色的资源。请帮忙

登录Activity.java

package com.androidapp;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;

public class LoginActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        TextView registerScreen = (TextView) findViewById(R.id.link_to_register);
        registerScreen.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v){
                Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
                startActivity(i);
            }
        });
    }


  /*  @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.login, menu);
        return true;
    }
    */
}

注册活动.java

package com.androidapp;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class RegisterActivity extends Activity{
    protected void onCreate(Bundle savedInstanceState){
     super.onCreate(savedInstanceState);
     setContentView(R.layout.register1);
     TextView loginScreen = (TextView) findViewById(R.id.link_to_login);

     loginScreen.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            finish();
        }
    });


    }
}

页脚重复.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/repeat_bg"
   android:tilemode="repeat" /> <--------problem

登录.xml

 <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#ffffff">

        <!-- Header -->
        <LinearLayout android:id="@+id/header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@layout/header_gradient"
            android:paddingTop="5dip"
            android:paddingBottom="5dip" >

            <ImageView android:src="@drawable/logo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dip"/>
        </LinearLayout>     

        <!-- Footer -->
        <LinearLayout android:id="@+id/footer"
            android:layout_width="fill_parent"
            android:layout_height="90dip"
            android:background="@layout/footer_repeat"
            android:layout_alignParentBottom="true">
               </LinearLayout>


        <!-- Login -->

        <LinearLayout 
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="10dip"
          android:layout_below="@id/header">
            <!-- For Email -->
            <TextView android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:textcolor="#372c24"
                    android:text="Email" />

            <EditText android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:layout_marginBottom="20dip"
                android:singleLine="true"/>

            <!-- For Pswd -->
            <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Password"/>
            <EditText android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:password="true"/>
            <Button android:id="@+id/btnLogin"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:text="Login"/>
            <TextView android:id="@+id/link_to_register"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="40dip"
                android:layout_marginBottom="40dip"
                android:text="New to Twitter? Register here"
                android:gravity="center"
                android:textSize="20dip"
                android:textColor="#0b84aa"/>

        </LinearLayout>
        <!-- Login -->



    </RelativeLayout>


    </ScrollView>

header_gradient.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
   <gradient android:startcolor="#24b2eb"
       android:centercolor="#4ccbff"
       android:endcolor="#24b2eb"
       android:angle="270" />
   <corners android:radius="5dp"/>
</shape>

注册1.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:fillViewport="true">
  <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#fff">

        <!--  Header  Starts-->
        <LinearLayout android:id="@+id/header"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@layout/header_gradient"
                android:paddingTop="5dip"
                android:paddingBottom="5dip">
                <!-- Logo Start-->
                <ImageView android:src="@drawable/logo"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dip"/>
                <!-- Logo Ends -->
        </LinearLayout>
        <!--  Header Ends -->
        <!-- Footer Start -->
        <LinearLayout android:id="@+id/footer"
                android:layout_width="fill_parent"
                android:layout_height="90dip"
                android:background="@layout/footer_repeat"
                android:layout_alignParentBottom="true">
        </LinearLayout>
        <!-- Footer Ends -->

        <!-- Registration Form -->
        <LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="10dip"
          android:layout_below="@id/header">
          <!-- Full Name Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Full Name"/>
          <EditText android:id="@+id/reg_fullname"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          <!--  Email Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Email"/>
          <EditText android:id="@+id/reg_email"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:layout_marginBottom="20dip"/>
          <!-- Password Label -->
          <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#372c24"
                android:text="Password"/>
          <EditText android:id="@+id/reg_password"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:password="true"
                android:singleLine="true"
                android:layout_marginTop="5dip"/>
          <!-- Register Button -->
          <Button android:id="@+id/btnRegister"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:text="Register New Account"/>
          <!-- Link to Login Screen -->
          <TextView android:id="@+id/link_to_login"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="40dip"
                android:layout_marginBottom="40dip"
                android:text="Already has account! Login here"
                android:gravity="center"
                android:textSize="20dip"
                android:textColor="#025f7c"/>

        </LinearLayout>
        <!-- Registration Form Ends -->
  </RelativeLayout>
</ScrollView>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".LoginActivity"
                  android:label="Login to your Account">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!--  Entry for RegisterActivity.class -->
        <activity android:name=".RegisterActivity"
                  android:label="Register New Account"></activity>

    </application>
</manifest>

日志猫

09-11 09:31:08.409: W/dalvikvm(818): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
09-11 09:31:08.529: E/AndroidRuntime(818): FATAL EXCEPTION: main
09-11 09:31:08.529: E/AndroidRuntime(818): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidapp/com.androidapp.LoginActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class <unknown>
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.os.Looper.loop(Looper.java:137)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.ActivityThread.main(ActivityThread.java:5041)
09-11 09:31:08.529: E/AndroidRuntime(818):  at java.lang.reflect.Method.invokeNative(Native Method)
09-11 09:31:08.529: E/AndroidRuntime(818):  at java.lang.reflect.Method.invoke(Method.java:511)
09-11 09:31:08.529: E/AndroidRuntime(818):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-11 09:31:08.529: E/AndroidRuntime(818):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-11 09:31:08.529: E/AndroidRuntime(818):  at dalvik.system.NativeStart.main(Native Method)
09-11 09:31:08.529: E/AndroidRuntime(818): Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class <unknown>
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
09-11 09:31:08.529: E/AndroidRuntime(818):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-11 09:31:08.529: E/AndroidRuntime(818):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.Activity.setContentView(Activity.java:1881)
09-11 09:31:08.529: E/AndroidRuntime(818):  at com.androidapp.LoginActivity.onCreate(LoginActivity.java:17)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.Activity.performCreate(Activity.java:5104)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-11 09:31:08.529: E/AndroidRuntime(818):  ... 11 more
09-11 09:31:08.529: E/AndroidRuntime(818): Caused by: java.lang.reflect.InvocationTargetException
09-11 09:31:08.529: E/AndroidRuntime(818):  at java.lang.reflect.Constructor.constructNative(Native Method)
09-11 09:31:08.529: E/AndroidRuntime(818):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
09-11 09:31:08.529: E/AndroidRuntime(818):  ... 25 more
09-11 09:31:08.529: E/AndroidRuntime(818): Caused by: java.lang.OutOfMemoryError
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:378)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:408)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:446)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:885)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.content.res.Resources.loadDrawable(Resources.java:1950)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.View.<init>(View.java:3330)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.view.ViewGroup.<init>(ViewGroup.java:431)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.widget.LinearLayout.<init>(LinearLayout.java:176)
09-11 09:31:08.529: E/AndroidRuntime(818):  at android.widget.LinearLayout.<init>(LinearLayout.java:172)
09-11 09:31:08.529: E/AndroidRuntime(818):  ... 28 more
4

0 回答 0