简体   繁体   中英

Animation screen works on phone but not tablet

So Ive made my first animation screen for my phone, this works perfect, and now I wanted to try it out on my tablet, but it crashes. The tablet is a Lenovo TAB3 7 Essential / Samsung SM-T550 . 崩溃日志

As you can see in the picture above it's line 34 setContentView(R.layout.activity_startscreen); the error occurs.

I've tried to Clean my project, but i think it might be in the .xml file?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#73FFFFFF"
    android:orientation="vertical"
    tools:context=".activitys.Startscreen">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <View
            android:id="@+id/first_line"
            android:layout_width="20dp"
            android:layout_height="50dp"
            android:layout_centerHorizontal="true"
            android:background="@drawable/blue_line" />

        <View
            android:id="@+id/second_line"
            android:layout_width="20dp"
            android:layout_height="200dp"
            android:layout_marginLeft="8dp"
            android:layout_toRightOf="@id/first_line"
            android:background="@drawable/gray_line" />

        <View
            android:id="@+id/third_line"
            android:layout_width="20dp"
            android:layout_height="150dp"
            android:layout_marginLeft="8dp"
            android:layout_toRightOf="@id/second_line"
            android:background="@drawable/blue_line" />

        <View
            android:id="@+id/fourth_line"
            android:layout_width="20dp"
            android:layout_height="250dp"
            android:layout_marginLeft="8dp"
            android:layout_toRightOf="@id/third_line"
            android:background="@drawable/gray_line" />

        <View
            android:id="@+id/fifth_line"
            android:layout_width="20dp"
            android:layout_height="100dp"
            android:layout_marginLeft="8dp"
            android:layout_toRightOf="@id/fourth_line"
            android:background="@drawable/blue_line" />

        <View
            android:id="@+id/six_line"
            android:layout_width="20dp"
            android:layout_height="50dp"
            android:layout_marginLeft="8dp"
            android:layout_toRightOf="@id/fifth_line"
            android:background="@drawable/gray_line" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="5dp">

        <ImageView
            android:id="@+id/wrd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            app:srcCompat="@drawable/logo_wrd" />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/tag"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="5dp"
            android:fontFamily="sans-serif-black"
            android:text="Wireless Rehab Device"
            android:textColor="#676767"
            android:textSize="24sp" />
    </RelativeLayout>


</LinearLayout>

The activity I showed Startscreen.java

public class Startscreen extends AppCompatActivity {

    private static int SPLASH_DURTION_OUT = 5000; // 5000ms = 5s

    //Views
    View first, second, third, fourth, fifth, sixth;
    TextView bottomTag;
    ImageView wrd;

    //Animations
    Animation topAnimation, bottomAnimation, middelAnimation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_startscreen);

        topAnimation = AnimationUtils.loadAnimation(this, R.anim.top_animation);
        bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.bottom_animation);
        middelAnimation = AnimationUtils.loadAnimation(this, R.anim.middel_animation);

        first = findViewById(R.id.first_line);
        second = findViewById(R.id.second_line);
        third = findViewById(R.id.third_line);
        fourth = findViewById(R.id.fourth_line);
        fifth = findViewById(R.id.fifth_line);
        sixth = findViewById(R.id.six_line);

        wrd = findViewById(R.id.wrd);
        bottomTag = findViewById(R.id.tag);

        //Animation settings
        first.setAnimation(topAnimation);
        second.setAnimation(topAnimation);
        third.setAnimation(topAnimation);
        fourth.setAnimation(topAnimation);
        fifth.setAnimation(topAnimation);
        sixth.setAnimation(topAnimation);

        wrd.setAnimation(middelAnimation);
        bottomTag.setAnimation(bottomAnimation);

        //Splash Screen
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(Startscreen.this, Home.class); //Home = Mainactivity
                startActivity(intent);
                finish();
            }
        }, SPLASH_DURTION_OUT);

    }
}

This is my Manifest

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

    <uses-feature
        android:name="android.hardware.bluetooth_le"
        android:required="true" />

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".activitys.Home" />
        <activity android:name=".activitys.Startscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name=".ble.BLE_Service"
            android:enabled="true" />

        <meta-data
            android:name="preloaded_fonts"
            android:resource="@array/preloaded_fonts" />
    </application>

</manifest>

发现问题了,我所有的.png图像都在我的Drawable-v24文件夹中,而不是Drawable ,所以现在修复了!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM