2016-07-31 79 views
-1

我正在试图在下面的图片中添加一个按钮,该图片是操作栏外的一半。我正在寻找一种标准的方式来设计它,因为它现在非常普遍。如何在半外部的操作栏上显示图像

感谢

enter image description here

+0

我很抱歉,如果它是那么明显,但我还是在学习阶段。 – Shubh

+0

你想要一个[FloatingActionButton](https://developer.android.com/reference/android/support/design/widget/FloatingActionButton.html) –

回答

1

你应该寻找 “FloatingActionButton”。

例如:

<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

     <LinearLayout 
      android:id="@+id/viewA" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.15"> 

      </LinearLayout> 

     <LinearLayout 
      android:id="@+id/viewB" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="0.85" > 

     </LinearLayout> 

    </LinearLayout> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/btn_add" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/activity_horizontal_margin" 
     android:clickable="true" 
     android:src="@drawable/ic_ok" 
     app:layout_anchor="@id/viewA" 
     app:layout_anchorGravity="left|bottom" 
     app:backgroundTint="@color/accent"/> 

</android.support.design.widget.CoordinatorLayout>