2012-04-26 63 views
0

我有一个在图像视图下具有adview的布局。在某些情况下,我使imageview不可见,这使得我的adview无法正确调整,因为(android:layout_below attribute我已经给我的广告)。当视图不可见时在视图下放置adview

`

<ImageView 
    android:id="@+id/previous" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_marginLeft="5dp" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/le" 
    android:clickable="true" 
    android:contentDescription="@string/app_name" 
    android:onClick="previous" 
    android:paddingBottom="3dp" > 
</ImageView> 

<ImageView 
    android:id="@+id/next" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="5dp" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/ri" 
    android:clickable="true" 
    android:contentDescription="@string/app_name" 
    android:onClick="next" 
    android:paddingBottom="3dp" > 
</ImageView> 

<com.google.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="PUB ID" 
     android:layout_below="@+id/next" 
     ads:loadAdOnCreate="true" /> 

<TextView 
    android:id="@+id/tv" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="18dp" 
    android:layout_below="@+id/adView" 
    android:textColor="@color/red" 
    android:textSize="20dp" 
    android:textStyle="bold" /> 

<ListView 
    android:id="@+id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/tv" 
    android:layout_marginTop="6dp" 
    android:cacheColorHint="#00000000" 
    android:clickable="false" 
    android:dividerHeight="30.0dp" 
    android:fadingEdge="none" 
    android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:scrollbars="none" > 
</ListView> 

`

我已经使用Layout_above属性为AdView中把它上面的TextView因为TextView的总是visible.But当我这样做,我得到了一个错误说循环依赖是不可能在相关的布局中.Below是更好理解的图像。

enter image description here

我该如何解决this.Any建议表示赞赏。

+0

给出完整的xml布局。它从上面的代码中不清楚你使用LinearLayot或者relativeLayout作为viewGroup。我想它应该是相对布局 – 2012-04-26 09:35:19

+0

我已经使用了相对布局的两个图像浏览器,并给出了相对布局的编号,以便adview的layoutbelow和它解决.. – 2012-04-26 09:35:39

回答

3

你是如何使ImageView隐形的?如果您使用imgView.setVisibility(View.INVISIBLE),则adView应保持其位置。

+0

imageview.setVisibility(View.GONE); – 2012-04-26 09:37:03

+0

将其更改为'View.INVISIBLE',因为这样做不会从布局(包含在度量阶段中)移除'ImageView',只是使其不可见。我想这就是你需要的。 – Rajesh 2012-04-26 09:38:55

+0

是的,改变这也工作.. – 2012-04-26 09:49:13