2017-07-10 15 views
0

フローティングアクションボタンで何らかの操作をしています。私はリストビューを持って、画面の下にGoogle広告を表示しています。浮動アクションボタンは同じ場所に表示されています(下端|)。アクションボタンは広告を隠しています。レイアウトの上にフローティングアクションボタンを配置する方法

フローティングアクションボタンを広告の線形レイアウトの少し上に移動します。

画像を見ていてください助けてください

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="@dimen/fab_margin" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentRight="true" 
    android:layout_gravity="bottom|end" 
    android:src="@drawable/fav" 
    android:adjustViewBounds="false" /> 


adLayoutId is ad layout id 

enter image description here

私のコードは次のようになります。

ありがとうございます。

答えて

1

あなたはRelativeLayoutを使用する必要があり、私たちが知っているように、RelativeLayoutの後の子供たちはRelativeLayoutで、以前の子どもたちの上に浮く傾向にあります。

したがって、任意のレイアウトのFABを浮動させるには、XMLレイアウトの最後にあるすべてのビューの後にFABが定義されていることを確認してください。

あなたがandroid:layout_margin="@dimen/fab_margin"を使用している場合はFABを操作するための最良の方法は、例えば、ビュー間の依存関係を設定されています

<?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"> 

    <ListView 
     android:id="@+id/listView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/adLayoutId"/> 

    <LinearLayout 
     android:id="@+id/adLayoutId" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:layout_alignParentBottom="true" 
     android:background="@android:color/black"/> 

    <android.support.design.widget.FloatingActionButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/adLayoutId" 
     android:layout_alignParentRight="true" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@drawable/fav"/> 
</RelativeLayout> 

は常に広告リニアレイアウト上にあること、および広告のレイアウトサイズから独立しますアクションボタンをフローティング。 お手伝いをしてください。

+0

ありがとう、それは魅力のように動作します.... – itin

0

は、フローティングボタンまたは囲むレイアウトのいずれかでこの行AdMobのバナー

の大きさである55dpの下の余白を追加します。

android:layout_marginBottom="55dp

0
<android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_marginBottom="100dp" 
     android:layout_marginRight="30dp" 
     /> 
+0

これは間違いなくあなたの問題を解決します。 – Saint

関連する問題