2013-03-30 104 views
0

我必须为每一个网格的自定义网格视图我使用显示两个图像之一的Android上面的另一个图像

<?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:orientation="vertical" > 

<View 
    android:layout_width="fill_parent" 
    android:layout_height="30sp" 
    android:layout_marginTop="85sp" 
    android:background="@drawable/shelf" /> 

<ImageView 
    android:id="@+id/imgThumb" 
    android:layout_width="47.5sp" 
    android:layout_height="76sp" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="29sp" 
    android:background="@drawable/pic1" /> 

<ImageView 
    android:id="@+id/bookCover" 
    android:layout_width="60sp" 
    android:layout_height="80sp" 
    android:layout_marginLeft="127sp" 
    android:layout_marginTop="26sp" 
    android:background="@drawable/book_cover" /> 

它看起来像这样的图形布局之前在eclipseenter image description here

但是当我在仿真器上运行它时,它看起来像 enter image description here

封面影像消失了,我在Android的新请不要哪里出了问题,该如何解决呢

** FrameLayout里也没有工作**

回答

0

尝试改变,因为这:

<?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="@drawable/shelf" > 

<ImageView 
    android:id="@+id/imgThumb" 
    android:layout_width="47.5sp" 
    android:layout_height="76sp" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="29sp" 
    android:background="@drawable/pic1" /> 

<ImageView 
    android:id="@+id/bookCover" 
    android:layout_below="@id/imgThumb" 
    android:layout_width="60sp" 
    android:layout_height="80sp" 
    android:layout_marginLeft="127sp" 
    android:layout_marginTop="26sp" 
    android:background="@drawable/book_cover" /> 

所以你的背景将被显示。方向不会出现在RelativeLayout中。

+0

不可能我需要把 '机器人:layout_height = “30sp” 机器人:layout_marginTop = “85sp”' @绘制/架viewtag内 – Anirban

0

使用下面的代码

  <RelativeLayout 
      android:id="@+id/dummy" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      > 

      <ImageView 
       android:id="@+id/pitch" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:background="@drawable/pic1" 
       android:scaleType="fitXY" /> 

      <ImageView 
       android:id="@+id/image1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="80sp" 
       android:layout_marginTop="50sp" 
       android:background="@drawable/book_cover" /> 
     </RelativeLayout> 
相关问题