Change alignment of icon and text in custom bottom navigation bar in android
up vote
0
down vote
favorite
I am using "com.luseen.spacenavigation.SpaceNavigationView" for my custom BottomNavigation bar. It works fine but my issue is with alignment of the icon and text in the bottom navigation bar. It aligned horizontally , but i want text to align below the icon. How can I change the alignment?
My XML
<com.luseen.spacenavigation.SpaceNavigationView
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
app:active_item_color="@color/colorAccent"
app:centre_button_color="@android:color/holo_green_light"
app:inactive_item_color="@android:color/darker_gray"
app:space_background_color="@android:color/holo_green_light"
app:centre_button_icon="@drawable/img1"
app:space_item_icon_size="@dimen/space_item_icon_default_size"
app:space_item_icon_only_size="@dimen/space_item_icon_only_size"
app:space_item_text_size="@dimen/space_item_text_default_size"
app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior"/>
In my Activity
spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
spaceNavigationView.addSpaceItem(new SpaceItem("Home", R.drawable.account));
spaceNavigationView.addSpaceItem(new SpaceItem("Help", R.drawable.ic_home_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Bookings", R.drawable.ic_dashboard_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Settings", R.drawable.ic_notifications_black_24dp));
spaceNavigationView.shouldShowFullBadgeText(true);
spaceNavigationView.setCentreButtonIconColorFilterEnabled(false);
spaceNavigationView.setSpaceBackgroundColor(Color.WHITE);
spaceNavigationView.setBackgroundColor(Color.GREEN);
android bottomnavigationview
add a comment |
up vote
0
down vote
favorite
I am using "com.luseen.spacenavigation.SpaceNavigationView" for my custom BottomNavigation bar. It works fine but my issue is with alignment of the icon and text in the bottom navigation bar. It aligned horizontally , but i want text to align below the icon. How can I change the alignment?
My XML
<com.luseen.spacenavigation.SpaceNavigationView
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
app:active_item_color="@color/colorAccent"
app:centre_button_color="@android:color/holo_green_light"
app:inactive_item_color="@android:color/darker_gray"
app:space_background_color="@android:color/holo_green_light"
app:centre_button_icon="@drawable/img1"
app:space_item_icon_size="@dimen/space_item_icon_default_size"
app:space_item_icon_only_size="@dimen/space_item_icon_only_size"
app:space_item_text_size="@dimen/space_item_text_default_size"
app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior"/>
In my Activity
spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
spaceNavigationView.addSpaceItem(new SpaceItem("Home", R.drawable.account));
spaceNavigationView.addSpaceItem(new SpaceItem("Help", R.drawable.ic_home_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Bookings", R.drawable.ic_dashboard_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Settings", R.drawable.ic_notifications_black_24dp));
spaceNavigationView.shouldShowFullBadgeText(true);
spaceNavigationView.setCentreButtonIconColorFilterEnabled(false);
spaceNavigationView.setSpaceBackgroundColor(Color.WHITE);
spaceNavigationView.setBackgroundColor(Color.GREEN);
android bottomnavigationview
you mean this library github.com/armcha/Space-Navigation-View?
– Touhidul Islam
Nov 20 at 5:24
yes, implementation 'com.github.armcha:SpaceNavigationView:1.6.0' this the implementation i n gradle
– visakh r
Nov 20 at 5:25
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using "com.luseen.spacenavigation.SpaceNavigationView" for my custom BottomNavigation bar. It works fine but my issue is with alignment of the icon and text in the bottom navigation bar. It aligned horizontally , but i want text to align below the icon. How can I change the alignment?
My XML
<com.luseen.spacenavigation.SpaceNavigationView
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
app:active_item_color="@color/colorAccent"
app:centre_button_color="@android:color/holo_green_light"
app:inactive_item_color="@android:color/darker_gray"
app:space_background_color="@android:color/holo_green_light"
app:centre_button_icon="@drawable/img1"
app:space_item_icon_size="@dimen/space_item_icon_default_size"
app:space_item_icon_only_size="@dimen/space_item_icon_only_size"
app:space_item_text_size="@dimen/space_item_text_default_size"
app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior"/>
In my Activity
spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
spaceNavigationView.addSpaceItem(new SpaceItem("Home", R.drawable.account));
spaceNavigationView.addSpaceItem(new SpaceItem("Help", R.drawable.ic_home_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Bookings", R.drawable.ic_dashboard_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Settings", R.drawable.ic_notifications_black_24dp));
spaceNavigationView.shouldShowFullBadgeText(true);
spaceNavigationView.setCentreButtonIconColorFilterEnabled(false);
spaceNavigationView.setSpaceBackgroundColor(Color.WHITE);
spaceNavigationView.setBackgroundColor(Color.GREEN);
android bottomnavigationview
I am using "com.luseen.spacenavigation.SpaceNavigationView" for my custom BottomNavigation bar. It works fine but my issue is with alignment of the icon and text in the bottom navigation bar. It aligned horizontally , but i want text to align below the icon. How can I change the alignment?
My XML
<com.luseen.spacenavigation.SpaceNavigationView
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
app:active_item_color="@color/colorAccent"
app:centre_button_color="@android:color/holo_green_light"
app:inactive_item_color="@android:color/darker_gray"
app:space_background_color="@android:color/holo_green_light"
app:centre_button_icon="@drawable/img1"
app:space_item_icon_size="@dimen/space_item_icon_default_size"
app:space_item_icon_only_size="@dimen/space_item_icon_only_size"
app:space_item_text_size="@dimen/space_item_text_default_size"
app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior"/>
In my Activity
spaceNavigationView = (SpaceNavigationView) findViewById(R.id.space);
spaceNavigationView.initWithSaveInstanceState(savedInstanceState);
spaceNavigationView.addSpaceItem(new SpaceItem("Home", R.drawable.account));
spaceNavigationView.addSpaceItem(new SpaceItem("Help", R.drawable.ic_home_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Bookings", R.drawable.ic_dashboard_black_24dp));
spaceNavigationView.addSpaceItem(new SpaceItem("Settings", R.drawable.ic_notifications_black_24dp));
spaceNavigationView.shouldShowFullBadgeText(true);
spaceNavigationView.setCentreButtonIconColorFilterEnabled(false);
spaceNavigationView.setSpaceBackgroundColor(Color.WHITE);
spaceNavigationView.setBackgroundColor(Color.GREEN);
android bottomnavigationview
android bottomnavigationview
asked Nov 20 at 5:21
visakh r
427
427
you mean this library github.com/armcha/Space-Navigation-View?
– Touhidul Islam
Nov 20 at 5:24
yes, implementation 'com.github.armcha:SpaceNavigationView:1.6.0' this the implementation i n gradle
– visakh r
Nov 20 at 5:25
add a comment |
you mean this library github.com/armcha/Space-Navigation-View?
– Touhidul Islam
Nov 20 at 5:24
yes, implementation 'com.github.armcha:SpaceNavigationView:1.6.0' this the implementation i n gradle
– visakh r
Nov 20 at 5:25
you mean this library github.com/armcha/Space-Navigation-View?
– Touhidul Islam
Nov 20 at 5:24
you mean this library github.com/armcha/Space-Navigation-View?
– Touhidul Islam
Nov 20 at 5:24
yes, implementation 'com.github.armcha:SpaceNavigationView:1.6.0' this the implementation i n gradle
– visakh r
Nov 20 at 5:25
yes, implementation 'com.github.armcha:SpaceNavigationView:1.6.0' this the implementation i n gradle
– visakh r
Nov 20 at 5:25
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
you have to edit the space_item_view.xml
layout file, inside the library to solve this problem.
space_item_view.xml
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:id="@+id/space_icon"
android:layout_width="@dimen/space_item_icon_default_size"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_height="@dimen/space_item_icon_default_size" />
<TextView
android:id="@+id/space_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:lines="1"
android:layout_centerHorizontal="true"
android:layout_below="@+id/space_icon"
android:gravity="center"
android:textSize="@dimen/space_item_text_default_size"
tools:text="Label One" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/badge_container"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/badge_left_margin"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/main_content"
android:visibility="gone">
<TextView
android:id="@+id/badge_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@android:color/white"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
Go to SpaceNavigationView.java
class and modify this only.
public void showIconOnly(boolean value) {
isIconOnlyMode = value;
}
and in your activity/fragment where you want to implement this simply replace this spaceNavigationView.showIconOnly();
to spaceNavigationView.showIconOnly(false);
found in this reply
I am using this implementation in gradle file, so how can I edit it?
– visakh r
Nov 20 at 6:45
1.clone the projec(github.com/armcha/Space-Navigation-View)t,2. copy rspacelib directory to your app. 3. change your gradle like this (github.com/armcha/Space-Navigation-View/blob/master/Sample/…)
– Touhidul Islam
Nov 20 at 8:02
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
you have to edit the space_item_view.xml
layout file, inside the library to solve this problem.
space_item_view.xml
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:id="@+id/space_icon"
android:layout_width="@dimen/space_item_icon_default_size"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_height="@dimen/space_item_icon_default_size" />
<TextView
android:id="@+id/space_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:lines="1"
android:layout_centerHorizontal="true"
android:layout_below="@+id/space_icon"
android:gravity="center"
android:textSize="@dimen/space_item_text_default_size"
tools:text="Label One" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/badge_container"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/badge_left_margin"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/main_content"
android:visibility="gone">
<TextView
android:id="@+id/badge_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@android:color/white"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
Go to SpaceNavigationView.java
class and modify this only.
public void showIconOnly(boolean value) {
isIconOnlyMode = value;
}
and in your activity/fragment where you want to implement this simply replace this spaceNavigationView.showIconOnly();
to spaceNavigationView.showIconOnly(false);
found in this reply
I am using this implementation in gradle file, so how can I edit it?
– visakh r
Nov 20 at 6:45
1.clone the projec(github.com/armcha/Space-Navigation-View)t,2. copy rspacelib directory to your app. 3. change your gradle like this (github.com/armcha/Space-Navigation-View/blob/master/Sample/…)
– Touhidul Islam
Nov 20 at 8:02
add a comment |
up vote
1
down vote
accepted
you have to edit the space_item_view.xml
layout file, inside the library to solve this problem.
space_item_view.xml
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:id="@+id/space_icon"
android:layout_width="@dimen/space_item_icon_default_size"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_height="@dimen/space_item_icon_default_size" />
<TextView
android:id="@+id/space_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:lines="1"
android:layout_centerHorizontal="true"
android:layout_below="@+id/space_icon"
android:gravity="center"
android:textSize="@dimen/space_item_text_default_size"
tools:text="Label One" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/badge_container"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/badge_left_margin"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/main_content"
android:visibility="gone">
<TextView
android:id="@+id/badge_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@android:color/white"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
Go to SpaceNavigationView.java
class and modify this only.
public void showIconOnly(boolean value) {
isIconOnlyMode = value;
}
and in your activity/fragment where you want to implement this simply replace this spaceNavigationView.showIconOnly();
to spaceNavigationView.showIconOnly(false);
found in this reply
I am using this implementation in gradle file, so how can I edit it?
– visakh r
Nov 20 at 6:45
1.clone the projec(github.com/armcha/Space-Navigation-View)t,2. copy rspacelib directory to your app. 3. change your gradle like this (github.com/armcha/Space-Navigation-View/blob/master/Sample/…)
– Touhidul Islam
Nov 20 at 8:02
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
you have to edit the space_item_view.xml
layout file, inside the library to solve this problem.
space_item_view.xml
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:id="@+id/space_icon"
android:layout_width="@dimen/space_item_icon_default_size"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_height="@dimen/space_item_icon_default_size" />
<TextView
android:id="@+id/space_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:lines="1"
android:layout_centerHorizontal="true"
android:layout_below="@+id/space_icon"
android:gravity="center"
android:textSize="@dimen/space_item_text_default_size"
tools:text="Label One" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/badge_container"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/badge_left_margin"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/main_content"
android:visibility="gone">
<TextView
android:id="@+id/badge_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@android:color/white"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
Go to SpaceNavigationView.java
class and modify this only.
public void showIconOnly(boolean value) {
isIconOnlyMode = value;
}
and in your activity/fragment where you want to implement this simply replace this spaceNavigationView.showIconOnly();
to spaceNavigationView.showIconOnly(false);
found in this reply
you have to edit the space_item_view.xml
layout file, inside the library to solve this problem.
space_item_view.xml
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:id="@+id/space_icon"
android:layout_width="@dimen/space_item_icon_default_size"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_height="@dimen/space_item_icon_default_size" />
<TextView
android:id="@+id/space_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:lines="1"
android:layout_centerHorizontal="true"
android:layout_below="@+id/space_icon"
android:gravity="center"
android:textSize="@dimen/space_item_text_default_size"
tools:text="Label One" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/badge_container"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/badge_left_margin"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/main_content"
android:visibility="gone">
<TextView
android:id="@+id/badge_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@android:color/white"
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
Go to SpaceNavigationView.java
class and modify this only.
public void showIconOnly(boolean value) {
isIconOnlyMode = value;
}
and in your activity/fragment where you want to implement this simply replace this spaceNavigationView.showIconOnly();
to spaceNavigationView.showIconOnly(false);
found in this reply
answered Nov 20 at 6:25
Touhidul Islam
640114
640114
I am using this implementation in gradle file, so how can I edit it?
– visakh r
Nov 20 at 6:45
1.clone the projec(github.com/armcha/Space-Navigation-View)t,2. copy rspacelib directory to your app. 3. change your gradle like this (github.com/armcha/Space-Navigation-View/blob/master/Sample/…)
– Touhidul Islam
Nov 20 at 8:02
add a comment |
I am using this implementation in gradle file, so how can I edit it?
– visakh r
Nov 20 at 6:45
1.clone the projec(github.com/armcha/Space-Navigation-View)t,2. copy rspacelib directory to your app. 3. change your gradle like this (github.com/armcha/Space-Navigation-View/blob/master/Sample/…)
– Touhidul Islam
Nov 20 at 8:02
I am using this implementation in gradle file, so how can I edit it?
– visakh r
Nov 20 at 6:45
I am using this implementation in gradle file, so how can I edit it?
– visakh r
Nov 20 at 6:45
1.clone the projec(github.com/armcha/Space-Navigation-View)t,2. copy rspacelib directory to your app. 3. change your gradle like this (github.com/armcha/Space-Navigation-View/blob/master/Sample/…)
– Touhidul Islam
Nov 20 at 8:02
1.clone the projec(github.com/armcha/Space-Navigation-View)t,2. copy rspacelib directory to your app. 3. change your gradle like this (github.com/armcha/Space-Navigation-View/blob/master/Sample/…)
– Touhidul Islam
Nov 20 at 8:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386677%2fchange-alignment-of-icon-and-text-in-custom-bottom-navigation-bar-in-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you mean this library github.com/armcha/Space-Navigation-View?
– Touhidul Islam
Nov 20 at 5:24
yes, implementation 'com.github.armcha:SpaceNavigationView:1.6.0' this the implementation i n gradle
– visakh r
Nov 20 at 5:25