0
A
回答
0
添加工具欄或appbar或者低於這個觀點你要顯示的影子。
<View
android:id="@+id/shadow_layout"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_dropshadow" />
------- ------ toolbar_dropshadow.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
0
設置android:elevation
到Toolbar
如果你的目標是Android 5.0及以上或預棒棒糖做以下。
Toolbar.xml
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<View
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/shadow" />
</LinearLayout>
shadow.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/no_color"
android:endColor="@color/shadow_normal"
android:angle="90" />
</shape>
color.xml
<color name="shadow_normal">#55000000</color>
<color name="no_color">#00000000</color>
0
,你可以簡單地使用財產海拔的android:海拔
<android.support.v7.widget.Toolbar
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="wrap_content"
android:elevation="8dp"
android:minHeight="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.v7.widget.Toolbar>
如果(Build.VERSION.SDK_INT < 21),使用帶有陰影背景視圖的FrameLayout裏面的工具欄下面
給出如下面
<include
android:id="@+id/my_action_bar"
layout="@layout/toolbar" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- activity content here.... -->
<View
android:id="@+id/view_toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_shadow" />
</FrameLayout>
在活動代碼
,你可以隱藏,如果個影子觀點dk版本> = 21
View mToolbarShadow = findViewById(R.id.view_toolbar_shadow);
if (Build.VERSION.SDK_INT >= 21) {
mToolbarShadow.setVisibility(View.GONE);
}
相關問題
- 1. 未在兒童活動中顯示工具欄
- 2. 在兒童活動中顯示DialogFragment Android
- 3. 工具欄沒有顯示?
- 4. 工具欄標題沒有顯示在標籤式活動中
- 5. 所有活動中的Android工具欄
- 6. Android工具欄沒有顯示的動作按鈕
- 7. wp_list_pages功能沒有顯示兒童
- 8. 顯示內嵌flex影響兒童?
- 9. Android的佈局沒有顯示所有兒童
- 10. ExpandableListView兒童活動
- 11. Android活動沒有顯示
- 12. 如何處理Android兒童活動沒有完成
- 13. Android設置兒童意圖動作欄
- 14. activity.setSupportActionBar(工具欄)沒有顯示工具欄
- 15. Android Studio工具欄自動顯示
- 16. Android:工具欄未顯示
- 17. 工具欄不顯示android
- 18. 獲取兒童活動子樹
- 19. 沒有顯示工具欄按鈕
- 20. 沒有顯示工具欄標題
- 21. 工具欄在沒有顯示
- 22. CKEDITOR工具欄沒有完全顯示
- 23. Android活動工具欄上一個按鈕不顯示
- 24. Android完成兒童活動錯誤
- 25. SlidingMenu兒童活動導航Android
- 26. 作爲對話框顯示的活動有一個工具欄
- 27. 是否有可能在開始兒童活動時顯示alertDialog仍然顯示?
- 28. Xamarin中的工具欄Android沒有顯示圖標
- 29. ItemsControl兒童活動WPF C#
- 30. 兒童活動繼承父活動
您的定位API> = 21? –
是我的目標API是22 – Vennila