2017-05-23 28 views
0

你好我目前有這個消息時,我嘗試我的應用程序部署到仿真器和它發生正是我附上佈局的活性,即的Java,Lang.OutOfMemoryError上Xamarin的Android部署

SetContentView(Resource.Layout.Main); 

的完整的錯誤消息說「無法與1048576個免費字節和95,直到OOM分配6569942字節分配

這裏是我的佈局:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http//schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/coordLayout" 
    tools:context=".MainActivity"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
      <ImageView 
       android:layout_marginTop="40sp" 
       android:id="@+id/logo" 
       android:layout_width="200sp" 
       android:layout_height="200sp" 
       android:src="@drawable/cpdep" 
       android:layout_gravity="center_horizontal" /> 
      <EditText 
       android:id="@+id/user" 
       android:layout_marginTop="20sp" 
       android:layout_gravity="center_horizontal" 
       android:layout_width="300sp" 
       android:layout_height="wrap_content" 
       android:hint="Username" /> 
      <EditText 
       android:id="@+id/pass" 
       android:layout_gravity="center_horizontal" 
       android:layout_width="300sp" 
       android:layout_height="wrap_content" 
       android:hint="Password" 
       android:layout_marginTop="20sp" /> 
      <Button 
       android:layout_marginTop="20sp" 
       android:layout_marginRight="40sp" 
       android:id="@+id/myButton" 
       android:layout_width="100sp" 
       android:layout_height="wrap_content" 
       android:text="Log in" 
       android:layout_gravity="right" /> 
    </LinearLayout> 
</android.support.design.widget.CoordinatorLayout> 

你有呃關於如何解決這個問題的想法?在此先感謝您的幫助

+1

你的佈局是怎樣的?你能否更新顯示這個的原始文章? – apineda

+0

是的,當然如果這可以幫助 – Geeksan

+1

你想嘗試更新所有你「sp」到「dp」除了textSize(如果有的話)?這就是說你將擁有寬度爲200dp,高度爲200dp的ImageView。 – apineda

回答

1

我弄清楚出了什麼問題,這是因爲我在佈局中使用的圖像的大小。它是2.89 MB,分辨率爲6200x6199。我用photoshop調整大小,一切工作都正常,這要歸功於@apenide