英文:
Animation screen works on phone but not tablet
问题
我已经为我的手机制作了第一个动画屏幕,这个动画在手机上运行得很好,现在我想在平板电脑上试试,但是它却崩溃了。
这个平板是 Lenovo TAB3 7 Essential / Samsung SM-T550。
正如你在上面的图片中所看到的,它是在第34行 setContentView(R.layout.activity_startscreen); 处发生了错误。
我尝试过对项目进行了 Clean 操作,但我认为问题可能出在 .xml 文件中。
以下是你提供的 .xml 文件的翻译部分:
<?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">
    <!-- ... 省略其他部分 ... -->
</LinearLayout>
以下是你提供的 Startscreen.java 的翻译部分:
public class Startscreen extends AppCompatActivity {
    // ... 省略其他部分 ...
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_startscreen);
        // ... 省略其他部分 ...
    }
}
以下是你提供的 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>
若有其他需要翻译的部分,请随时提问。
英文:
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>
答案1
得分: 1
发现问题了,所有我的.png图片都放在了Drawable-v24文件夹中,而不是Drawable文件夹,所以现在问题已经解决了!
英文:
Found the issue, all my .png images was in my Drawable-v24 folder and not Drawable, so it's fixed now!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论