动画屏幕在手机上正常工作但在平板上不正常

huangapple go评论66阅读模式
英文:

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?

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

    &lt;RelativeLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&gt;

        &lt;View
            android:id=&quot;@+id/first_line&quot;
            android:layout_width=&quot;20dp&quot;
            android:layout_height=&quot;50dp&quot;
            android:layout_centerHorizontal=&quot;true&quot;
            android:background=&quot;@drawable/blue_line&quot; /&gt;

        &lt;View
            android:id=&quot;@+id/second_line&quot;
            android:layout_width=&quot;20dp&quot;
            android:layout_height=&quot;200dp&quot;
            android:layout_marginLeft=&quot;8dp&quot;
            android:layout_toRightOf=&quot;@id/first_line&quot;
            android:background=&quot;@drawable/gray_line&quot; /&gt;

        &lt;View
            android:id=&quot;@+id/third_line&quot;
            android:layout_width=&quot;20dp&quot;
            android:layout_height=&quot;150dp&quot;
            android:layout_marginLeft=&quot;8dp&quot;
            android:layout_toRightOf=&quot;@id/second_line&quot;
            android:background=&quot;@drawable/blue_line&quot; /&gt;

        &lt;View
            android:id=&quot;@+id/fourth_line&quot;
            android:layout_width=&quot;20dp&quot;
            android:layout_height=&quot;250dp&quot;
            android:layout_marginLeft=&quot;8dp&quot;
            android:layout_toRightOf=&quot;@id/third_line&quot;
            android:background=&quot;@drawable/gray_line&quot; /&gt;

        &lt;View
            android:id=&quot;@+id/fifth_line&quot;
            android:layout_width=&quot;20dp&quot;
            android:layout_height=&quot;100dp&quot;
            android:layout_marginLeft=&quot;8dp&quot;
            android:layout_toRightOf=&quot;@id/fourth_line&quot;
            android:background=&quot;@drawable/blue_line&quot; /&gt;

        &lt;View
            android:id=&quot;@+id/six_line&quot;
            android:layout_width=&quot;20dp&quot;
            android:layout_height=&quot;50dp&quot;
            android:layout_marginLeft=&quot;8dp&quot;
            android:layout_toRightOf=&quot;@id/fifth_line&quot;
            android:background=&quot;@drawable/gray_line&quot; /&gt;

    &lt;/RelativeLayout&gt;

    &lt;RelativeLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_marginHorizontal=&quot;5dp&quot;&gt;

        &lt;ImageView
            android:id=&quot;@+id/wrd&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_centerHorizontal=&quot;true&quot;
            app:srcCompat=&quot;@drawable/logo_wrd&quot; /&gt;

    &lt;/RelativeLayout&gt;

    &lt;RelativeLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot;&gt;

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


&lt;/LinearLayout&gt;

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

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.example.wrd&quot;&gt;

    &lt;uses-feature
        android:name=&quot;android.hardware.bluetooth_le&quot;
        android:required=&quot;true&quot; /&gt;

    &lt;uses-permission android:name=&quot;android.permission.BLUETOOTH&quot; /&gt;
    &lt;uses-permission android:name=&quot;android.permission.BLUETOOTH_ADMIN&quot; /&gt;
    &lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;

    &lt;application
        android:allowBackup=&quot;true&quot;
        android:icon=&quot;@mipmap/ic_launcher&quot;
        android:label=&quot;@string/app_name&quot;
        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
        android:supportsRtl=&quot;true&quot;
        android:theme=&quot;@style/AppTheme&quot;&gt;
        &lt;activity android:name=&quot;.activitys.Home&quot; /&gt;
        &lt;activity android:name=&quot;.activitys.Startscreen&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

        &lt;service
            android:name=&quot;.ble.BLE_Service&quot;
            android:enabled=&quot;true&quot; /&gt;

        &lt;meta-data
            android:name=&quot;preloaded_fonts&quot;
            android:resource=&quot;@array/preloaded_fonts&quot; /&gt;
    &lt;/application&gt;

&lt;/manifest&gt;

答案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!

huangapple
  • 本文由 发表于 2020年9月30日 18:28:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/64135633.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定