2017-05-14 6 views
0

私は基本的には愚かなコードでスプラッシュ画面を持っています...私はほとんどのアンドロイドデバイスでそれを実行すると、それは動作しますが、画面サイズに依存しない4つのデバイス上でテスト)それはアプリがサムスンのデバイスでのみクラッシュする

LogCat- https://gist.github.com/anonymous/2c06feb8643dc1381db39b64e0834942

Crash--

E/AndroidRuntime: FATAL EXCEPTION: main 
java.lang.RuntimeException: Unable to start activity ComponentInfo{inc.bs.ksit/inc.bs.ksit.Splash}: android.view.InflateException: Binary XML file line #20: Error inflating class android.widget.ImageView 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2114) 

レイアウトファイル

...このエラーでクラッシュを引き起こしました10
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:background="@color/white" 
android:layout_width="match_parent" android:layout_height="match_parent"> 

<TextView 
    android:text="@string/app_name" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/imageView" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="48dp" 
    android:textSize="50sp" 
    android:id="@+id/textView13" 
    android:textStyle="bold" 
    android:textColor="@color/colorPrimaryDark" /> 

<ImageView 
    android:layout_width="170dp" 
    android:layout_height="200dp" 
    android:background="@drawable/images" 
    android:layout_marginTop="50dp" 
    android:id="@+id/imageView" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" /> 

<TextView 
    android:text="Powered by BS " 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/textView13" 
    android:layout_centerHorizontal="true" 
    android:id="@+id/textView14" /> 
</RelativeLayout> 

それは他のすべてのデバイス、任意のアイデアで動作しましたか? ImageViewへ ご参照あなたがそれを作成する前に、私はちょうどUI項目を並べ替えるきた、とあなたは元android:id="@+id/imageView"のために、ビューのidを宣言している場合:

スプラッシュ活動

public class Splash extends Activity { 

    // Splash screen timer 
    private static int SPLASH_TIME_OUT = 400; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splash); 
     Log.d("tag","splash"); 
     new Handler().postDelayed(new Runnable() { 

      /* 
      * Showing splash screen with a timer. This will be useful when you 
      * want to show case your app logo/company 
      */ 

      @Override 
      public void run() { 
       // This method will be executed once the timer is over 
       // Start your app main activity 
       Intent i = new Intent(Splash.this, MainActivity.class); 
       startActivity(i); 

       // close this activity 
       finish(); 
      } 
     }, SPLASH_TIME_OUT); 
    } 
} 
+0

はあなたのコードを入れても完全なログさ –

+0

がでそう尽くします数分...私はアップロードできないようにしようとしていたときに何らかのフォーマット問題が起こっていた – Firewolf

+0

イメージのサイズが大きすぎますか? – Swarnveer

答えて

0

更新android:layout_below="@+id/imageView"

これをチェックしてください場合は、次のrefrenceに +項目を削除し、そう android:layout_below="@id/imageView" isntadeを使用する必要があります
<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white"> 

    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="170dp" 
     android:layout_height="200dp" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="50dp" 
     android:background="@drawable/images" /> 

    <TextView 
     android:id="@+id/textView13" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/imageView" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="48dp" 
     android:text="@string/app_name" 
     android:textColor="@color/colorPrimaryDark" 
     android:textSize="50sp" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/textView14" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/textView13" 
     android:layout_centerHorizontal="true" 
     android:text="Powered by BS " /> 
</RelativeLayout> 
+0

いいえ、依然としてクラッシュする – Firewolf

+0

このコードを追加した理由を教えてください。 – Swarnveer

+0

@Swarnveerはこちらです説明 –

0

クラッシュは、現在使用している画像が原因である可能性があります。奇妙な次元があるはずです。 Glide

をあなたは別の画像を使用するか、またはあなたがイメージのキャッシュライブラリを使用することができます。このグライドを使用するためのサンプルコードを解決するため

Display display = getWindowManager().getDefaultDisplay(); 
int height = display.getHeight(); 
int width = display.getWidth(); 
final RelativeLayout layout = (RelativeLayout) findViewById(R.id.searchCityGuide); 
Glide.with(this).load(R.drawable.exploref).asBitmap().into(new SimpleTarget<Bitmap>((int) width, (int) height) { 
@Override 
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { 
     Drawable drawable = new BitmapDrawable(resource); 
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 
      layout.setBackground(drawable); 
      } 
     } 
    }); 
+0

explorefはイメージの名前です – Swarnveer

関連する問題