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. 如何做gouraud陰影?
- 2. 向Android Widget提升(陰影)
- 3. 如何做到在IE盒子陰影?
- 4. Android內陰影
- 5. 如何在android中爲陰影製作陰影效果?
- 6. 如何向UINavigationController添加陰影
- 7. 元素上的徑向框陰影
- 8. 陰影圓角Android
- 9. 如何y偏移Android 5棒棒糖陰影方向
- 10. Android:如何爲App Widget添加陰影
- 11. 如何爲android按鈕添加陰影
- 12. Android如何刪除文字陰影?
- 13. Css |內向箱子陰影?
- 14. UIView定向陰影問題
- 15. 向ImageView添加陰影
- 16. Android上的大文字陰影
- 17. 在Android的TabLayout上設置陰影
- 18. 更改Android上ImageView的陰影顏色
- 19. 在Android上顯示陰影方塊MapVIew
- 20. 如何設置android按鈕陰影而不是設置文字陰影
- 21. 如何在Android按鈕上創建陰影(材質設計)
- 22. 如何刪除默認Android活動上的通知欄陰影
- 23. 如何在android線性佈局上獲得陰影?
- 24. 如何擺脫出現在我的按鈕上的陰影? Android
- 25. 如何在Android應用程序UI上獲取陰影框?
- 26. React Native Android按鈕陰影
- 27. Android按鈕邊框陰影
- 28. Android的陰影下邊框
- 29. 底部陰影到ListPopupWindow android
- 30. Android XML:陰影中斷
的效果圖已經被附 – FanMingYi