Make the Bottom App Bar a standalone layout.

This commit is contained in:
Alex Ning 2020-12-08 23:46:44 +08:00
parent 22b0072b26
commit 7cf90856d6
7 changed files with 32 additions and 92 deletions

View File

@ -152,17 +152,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
RecyclerView navDrawerRecyclerView; RecyclerView navDrawerRecyclerView;
@BindView(R.id.tab_layout_main_activity) @BindView(R.id.tab_layout_main_activity)
TabLayout tabLayout; TabLayout tabLayout;
@BindView(R.id.bottom_app_bar_main_activity) @BindView(R.id.bottom_app_bar_bottom_app_bar)
BottomAppBar bottomAppBar; BottomAppBar bottomAppBar;
@BindView(R.id.linear_layout_bottom_app_bar_main_activity) @BindView(R.id.linear_layout_bottom_app_bar)
LinearLayout linearLayoutBottomAppBar; LinearLayout linearLayoutBottomAppBar;
@BindView(R.id.option_1_bottom_app_bar_main_activity) @BindView(R.id.option_1_bottom_app_bar)
ImageView option1BottomAppBar; ImageView option1BottomAppBar;
@BindView(R.id.option_2_bottom_app_bar_main_activity) @BindView(R.id.option_2_bottom_app_bar)
ImageView option2BottomAppBar; ImageView option2BottomAppBar;
@BindView(R.id.option_3_bottom_app_bar_main_activity) @BindView(R.id.option_3_bottom_app_bar)
ImageView option3BottomAppBar; ImageView option3BottomAppBar;
@BindView(R.id.option_4_bottom_app_bar_main_activity) @BindView(R.id.option_4_bottom_app_bar)
ImageView option4BottomAppBar; ImageView option4BottomAppBar;
@BindView(R.id.fab_main_activity) @BindView(R.id.fab_main_activity)
FloatingActionButton fab; FloatingActionButton fab;

View File

@ -150,17 +150,17 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
TextView creationTimeTextView; TextView creationTimeTextView;
@BindView(R.id.description_text_view_view_subreddit_detail_activity) @BindView(R.id.description_text_view_view_subreddit_detail_activity)
TextView descriptionTextView; TextView descriptionTextView;
@BindView(R.id.bottom_navigation_view_subreddit_detail_activity) @BindView(R.id.bottom_app_bar_bottom_app_bar)
BottomAppBar bottomNavigationView; BottomAppBar bottomNavigationView;
@BindView(R.id.linear_layout_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.linear_layout_bottom_app_bar)
LinearLayout linearLayoutBottomAppBar; LinearLayout linearLayoutBottomAppBar;
@BindView(R.id.option_1_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_1_bottom_app_bar)
ImageView option1BottomAppBar; ImageView option1BottomAppBar;
@BindView(R.id.option_2_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_2_bottom_app_bar)
ImageView option2BottomAppBar; ImageView option2BottomAppBar;
@BindView(R.id.option_3_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_3_bottom_app_bar)
ImageView option3BottomAppBar; ImageView option3BottomAppBar;
@BindView(R.id.option_4_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_4_bottom_app_bar)
ImageView option4BottomAppBar; ImageView option4BottomAppBar;
@BindView(R.id.fab_view_subreddit_detail_activity) @BindView(R.id.fab_view_subreddit_detail_activity)
FloatingActionButton fab; FloatingActionButton fab;

View File

@ -152,17 +152,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
TextView cakedayTextView; TextView cakedayTextView;
@BindView(R.id.description_text_view_view_user_detail_activity) @BindView(R.id.description_text_view_view_user_detail_activity)
TextView descriptionTextView; TextView descriptionTextView;
@BindView(R.id.bottom_navigation_view_subreddit_detail_activity) @BindView(R.id.bottom_app_bar_bottom_app_bar)
BottomAppBar bottomNavigationView; BottomAppBar bottomNavigationView;
@BindView(R.id.linear_layout_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.linear_layout_bottom_app_bar)
LinearLayout linearLayoutBottomAppBar; LinearLayout linearLayoutBottomAppBar;
@BindView(R.id.option_1_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_1_bottom_app_bar)
ImageView option1BottomAppBar; ImageView option1BottomAppBar;
@BindView(R.id.option_2_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_2_bottom_app_bar)
ImageView option2BottomAppBar; ImageView option2BottomAppBar;
@BindView(R.id.option_3_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_3_bottom_app_bar)
ImageView option3BottomAppBar; ImageView option3BottomAppBar;
@BindView(R.id.option_4_bottom_app_bar_view_subreddit_detail_activity) @BindView(R.id.option_4_bottom_app_bar)
ImageView option4BottomAppBar; ImageView option4BottomAppBar;
@BindView(R.id.fab_view_user_detail_activity) @BindView(R.id.fab_view_user_detail_activity)
FloatingActionButton fab; FloatingActionButton fab;

View File

@ -173,7 +173,7 @@
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<include <include
layout="@layout/bottom_app_bar_other_pages" layout="@layout/bottom_app_bar_other_activities"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" /> android:layout_gravity="bottom" />
@ -185,6 +185,6 @@
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone" android:visibility="gone"
app:tint="@android:color/white" app:tint="@android:color/white"
app:layout_anchor="@id/bottom_navigation_view_subreddit_detail_activity" /> app:layout_anchor="@id/bottom_app_bar_bottom_app_bar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -140,7 +140,7 @@
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<include <include
layout="@layout/bottom_app_bar_other_pages" layout="@layout/bottom_app_bar_other_activities"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" /> android:layout_gravity="bottom" />
@ -152,6 +152,6 @@
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone" android:visibility="gone"
app:tint="@android:color/white" app:tint="@android:color/white"
app:layout_anchor="@id/bottom_navigation_view_subreddit_detail_activity" /> app:layout_anchor="@id/bottom_app_bar_bottom_app_bar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -51,71 +51,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.bottomappbar.BottomAppBar <include
android:id="@+id/bottom_app_bar_main_activity" layout="@layout/bottom_app_bar_other_activities"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom" />
android:visibility="gone"
app:fabAlignmentMode="center">
<LinearLayout
android:id="@+id/linear_layout_bottom_app_bar_main_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="6dp"
android:weightSum="5">
<ImageView
android:id="@+id/option_1_bottom_app_bar_main_activity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="?attr/selectableItemBackgroundBorderless" />
<ImageView
android:id="@+id/option_2_bottom_app_bar_main_activity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="?attr/selectableItemBackgroundBorderless" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"/>
<ImageView
android:id="@+id/option_3_bottom_app_bar_main_activity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="?attr/selectableItemBackgroundBorderless" />
<ImageView
android:id="@+id/option_4_bottom_app_bar_main_activity"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:gravity="center"
android:background="?attr/selectableItemBackgroundBorderless" />
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_main_activity" android:id="@+id/fab_main_activity"
@ -124,6 +64,6 @@
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone" android:visibility="gone"
app:tint="@android:color/white" app:tint="@android:color/white"
app:layout_anchor="@id/bottom_app_bar_main_activity" /> app:layout_anchor="@id/bottom_app_bar_bottom_app_bar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.bottomappbar.BottomAppBar xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.bottomappbar.BottomAppBar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_navigation_view_subreddit_detail_activity" android:id="@+id/bottom_app_bar_bottom_app_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
app:fabAlignmentMode="center"> app:fabAlignmentMode="center">
<LinearLayout <LinearLayout
android:id="@+id/linear_layout_bottom_app_bar_view_subreddit_detail_activity" android:id="@+id/linear_layout_bottom_app_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="6dp" android:paddingTop="6dp"
android:weightSum="5"> android:weightSum="5">
<ImageView <ImageView
android:id="@+id/option_1_bottom_app_bar_view_subreddit_detail_activity" android:id="@+id/option_1_bottom_app_bar"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -25,7 +25,7 @@
android:background="?attr/selectableItemBackgroundBorderless" /> android:background="?attr/selectableItemBackgroundBorderless" />
<ImageView <ImageView
android:id="@+id/option_2_bottom_app_bar_view_subreddit_detail_activity" android:id="@+id/option_2_bottom_app_bar"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -41,7 +41,7 @@
android:background="@android:color/transparent"/> android:background="@android:color/transparent"/>
<ImageView <ImageView
android:id="@+id/option_3_bottom_app_bar_view_subreddit_detail_activity" android:id="@+id/option_3_bottom_app_bar"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -51,7 +51,7 @@
android:background="?attr/selectableItemBackgroundBorderless" /> android:background="?attr/selectableItemBackgroundBorderless" />
<ImageView <ImageView
android:id="@+id/option_4_bottom_app_bar_view_subreddit_detail_activity" android:id="@+id/option_4_bottom_app_bar"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"