2016-04-22 92 views
0

我试图为android中的主要活动(使用xamarin)设置背景图像。该图像显示在设计中,但当我模仿我的手机(Galaxy S4)不显示。这是代码。这里有什么问题?背景图像android xamarin

 <?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:src="@drawable/home" 
     android:scaleType="fitXY" /> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <GridLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:columnCount="1" 
      android:layout_gravity="bottom" 
      android:minHeight="250dp"> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:minHeight="125dp"> 
       <Space 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_weight="1" /> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button 1" 
        android:layout_gravity="center" /> 
       <Space 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_weight="1" /> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:text="Button 2" /> 
       <Space 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_weight="1" /> 
      </LinearLayout> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:minHeight="125dp"> 
       <Space 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_weight="1" /> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Button 3" 
        android:layout_gravity="center" /> 
       <Space 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_weight="1" /> 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:text="Button 4" /> 
       <Space 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:layout_weight="1" /> 
      </LinearLayout> 
     </GridLayout> 
    </LinearLayout> 
</RelativeLayout> 

回答

2

它可能很大。展控制台这样的错误:位图过大,无法上传到纹理(4350x2448,最大= 4096×4096)

尝试把图像绘制,nodpi

Android background image memory usage

+0

我使用Visual工作室2015这个android项目,我没有文件夹“drawable-nodpi”的解决方案,我只有文件夹“drawable”。我尝试了一个小图像(720x1280),因为这是一个(1080x1920),它的工作。这与图像分辨率有关,但我如何改变它以适应所有屏幕?谢谢 – CalinCosmin

+0

您可以将此文件夹添加到Resources文件夹中的解决方案:-) – iwanlenin

+0

我也试过这个,但它不知道在它们之间切换。 – CalinCosmin