2016-09-13 113 views
1

我需要在工具欄中部分顯示圖像,部分在視圖中。我沒有找到好的例子,也許有人知道如何做到這一點?我目前在Xamarin工作,但Android Studio的示例將對您有所幫助。在工具欄中添加圖像,但它必須大於工具欄

enter image description here

+0

我相信做到這一點的最佳方法是在工具欄底部製作一條半透明線條。幾周前我讀了一個關於它的問題,我會看看我能否找到它 – LBJ33

+0

http://stackoverflow.com/questions/39380159/how-do-i-make-an-icon-seem-like-it-sticks退房手續的最-工具欄 – LBJ33

回答

2

使用CoordinatorLayoutlayout_anchor

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

    <android.support.design.widget.AppBarLayout android:id="@+id/app_bar" 
     android:layout_width="match_parent" android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.ActionBar"> 

     <android.support.v7.widget.Toolbar android:id="@+id/toolbar" 
      android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

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

    <ImageView android:id="@+id/image_anchored" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_margin="16dp" android:src="@drawable/image_anchor" 
     app:layout_anchor="@id/app_bar" app:layout_anchorGravity="bottom|start|left"/> 

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

或許創造了一個ActionBar的自定義視圖?

而且你也可以爲ActionBar設置自定義高度。 然後我認爲你的內容可以落後於ActionBar。你也可以在ActionBar上使用透明度。