2017-05-08 6 views

答えて

4

あなたはFloatingActionButtonの標高属性を使用する必要があります。

標高= "8dp"が私のために働いた。

サンプルレイアウト:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1"> 

     <TextView 
      android:id="@+id/message" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="@dimen/activity_vertical_margin" 
      android:layout_marginLeft="@dimen/activity_horizontal_margin" 
      android:layout_marginRight="@dimen/activity_horizontal_margin" 
      android:layout_marginTop="@dimen/activity_vertical_margin" 
      android:text="@string/title_home" /> 

    </FrameLayout> 

    <android.support.design.widget.BottomNavigationView 
     android:id="@+id/navigation" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:background="?android:attr/windowBackground" 
     app:menu="@menu/navigation" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/floatingActionButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|center_horizontal" 
     android:layout_marginBottom="40dp" 
     android:clickable="true" 
     app:elevation="8dp" 
     app:srcCompat="@android:drawable/ic_input_add" /> 

</FrameLayout> 
+0

それは働いた! Bottom View要素間のスペースを、イメージにどのように表示されるかなどのように変更するにはどうすればよいですか? –

+1

残念ながら、元のクラスをオーバーライドしない限り、それはイメージのように見えるようにする範囲はあまりありません。慎重に観察すると、5つの要素があり、中間は空白です。これはトリックを行うだろう。希望はそれを助ける:) –

+0

私は下部バーのアイコンのサイズを増やすことができる方法はありますか?アイコンの大きさにかかわらず、常に同じサイズにとどまります! –

0

。それはアンドロイド自体の機能的な(ホーム/戻る/アプリケーション)ボタンではありません。

このように、任意のビューと同様に、ビューをお互いの上に置くことは容易ではありません。これはRelative layout

注意すべきもう一つのことを達成することができ

、アンドロイド活動テンプレートのいずれかが実際にあなたの写真に示したものと同様のホバリングボタンの例を作成し、アンドロイドスタジオ経由です。ウィザードを使用してアクティビティを作成し、必要に応じてボタンを移動します。

enter image description here

+0

作成できるボトムバーがあります。私は、下部のバーの中央のアイコンのような浮動アクションボタンを配置するための助けを求めています!私はどこでもそれを見つけることができませんでした –

+0

@MukundSrivathsanあなたがそれが他のものの上に上昇していることを意味するなら、上に示したアンドロイドスタジオの例、またはアブの答えを見てください。 – Doomsknight

0

あなたはFloatingActionButtonはXMLで属性を使用することができます。

FloatingActionButton layout_anchor (添付するビューのID) とlayout_anchorGravityを設定します。

関連する問題