Android 5.0 Material Design看起來不可能。Android如何做向上陰影
0
A
回答
0
你可以得到那樣的使用底部導航選項卡效果。 試試這個代碼,希望它可以幫助你
對於底部導航選項卡則必須將此行添加到依賴
compile ‘com.android.support:design:25.0.0’
這裏是MainActivity.Java
公共類MainActivity擴展AppCompatActivity { 私人BottomBar mBottomBar ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Notice how you don't use the setContentView method here! Just
// pass your layout to bottom bar, it will be taken care of.
// Everything will be just like you're used to.
mBottomBar = BottomBar.bind(this, R.layout.activity_main,
savedInstanceState);
mBottomBar.setItems(
new BottomBarTab(R.drawable.ic_recents, "Recents"),
new BottomBarTab(R.drawable.ic_favorites, "Favorites"),
new BottomBarTab(R.drawable.ic_nearby, "Nearby"),
new BottomBarTab(R.drawable.ic_friends, "Friends")
);
mBottomBar.setOnItemSelectedListener(new OnTabSelectedListener() {
@Override
public void onItemSelected(final int position) {
// the user selected a new tab
}
});
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mBottomBar.onSaveInstanceState(outState);
}
}
Design.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<!-- Content Container -->
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/bottom_navigation_main" />
</RelativeLayout>
menu.xml文件
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_favorites"
android:enabled="true"
android:icon="@drawable/ic_favorite_white_24dp"
android:title="@string/text_favorites"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_schedules"
android:enabled="true"
android:icon="@drawable/ic_access_time_white_24dp"
android:title="@string/text_schedules"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_music"
android:enabled="true"
android:icon="@drawable/ic_audiotrack_white_24dp"
android:title="@string/text_music"
app:showAsAction="ifRoom" />
</menu>
使用該
Enable/Disable選擇狀態<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white" android:state_enabled="true" />
<item android:color="@color/colorPrimaryDark" android:state_enabled="false" />
</selector>
手柄click事件在佈局
BottomNavigationView bottomNavigationView = (BottomNavigationView)
findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_favorites:
break;
case R.id.action_schedules:
break;
case R.id.action_music:
break;
}
return false;
}
});
0
添加視圖
<View
android:layout_width="fill_parent"
android:layout_height="5dip"
android:background="@drawable/drop_shadow" >
</View>
添加在您繪製文件夾drop_shadow.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#404040"
android:endColor="#F1F1F1"
android:angle="270"
>
</gradient>
</shape>
相關問題
- 1. 向Android Widget提升(陰影)
- 2. 如何做到在IE盒子陰影?
- 3. Android內陰影
- 4. 如何向UINavigationController添加陰影
- 5. 如何y偏移Android 5棒棒糖陰影方向
- 6. 如何爲android按鈕添加陰影
- 7. 在Android的TabLayout上設置陰影
- 8. 在Android上顯示陰影方塊MapVIew
- 9. 更改Android上ImageView的陰影顏色
- 10. Css |內向箱子陰影?
- 11. UIView定向陰影問題
- 12. 如何在android線性佈局上獲得陰影?
- 13. 如何擺脫出現在我的按鈕上的陰影? Android
- 14. Android ProgressDialog陰影出現
- 15. React Native Android按鈕陰影
- 16. 底部陰影到ListPopupWindow android
- 17. Android按鈕邊框陰影
- 18. Android的對話框陰影
- 19. Android和箱陰影財產
- 20. html下拉陰影最佳做法
- 21. 如何陰影底部
- 22. 如何在Chart.js中過濾陰影或陰影?
- 23. 投影表上翻轉的陰影?
- 24. iOS上的更強陰影
- 25. UIImageView問題上的陰影
- 26. iPad上的陰影裁剪
- 27. 你如何在OpenGL中做非線性陰影?
- 28. 如何設置一個盒子陰影的div元素的所有方面,左陰影,右陰影,頂部陰影,底部陰影?
- 29. OpenGL ES 2D陰影的陰影
- 30. 陰影質量(陰影痤瘡)
的效果圖已經被附 – FanMingYi