Display the icon at the right of the text in navigation view
sorry for my bad English.
I have a navigation drawer in some activities, I want the icon of each navigation view item to be placed to the right of that item's text and the whole item get right gravity.
Because I only used Persian in my app, I can not use "supportsRtl" in my code, if I use, it will look weird when I set device language to any rtl languages.
I think probably I can fix this with setting custom layout for navigation view, but I'm looking for a simpler way. this is my NavigationView XML code:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layout_gravity="end" />
Edited :
layoutDirection is a good answer but i used drawerLayout.openDrawer(GravityCompat.START);
for opening navigation drawer. now if device language be an rtl language this make app crash.
android navigation-drawer rtl-language
|
show 3 more comments
sorry for my bad English.
I have a navigation drawer in some activities, I want the icon of each navigation view item to be placed to the right of that item's text and the whole item get right gravity.
Because I only used Persian in my app, I can not use "supportsRtl" in my code, if I use, it will look weird when I set device language to any rtl languages.
I think probably I can fix this with setting custom layout for navigation view, but I'm looking for a simpler way. this is my NavigationView XML code:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layout_gravity="end" />
Edited :
layoutDirection is a good answer but i used drawerLayout.openDrawer(GravityCompat.START);
for opening navigation drawer. now if device language be an rtl language this make app crash.
android navigation-drawer rtl-language
Try to add Custom Listview or RecylerView in Navigation drawer
– Sniffer
Jan 3 at 10:08
thanks, it is a good way but in that case i will need a layout for item and an adapter class ,... . my code will become very longer only for solving this rtl problem . i'm looking for a simpler way or an custom library for it.
– danial abadi ghadim
Jan 3 at 10:16
This might help stackoverflow.com/questions/33464416/…
– okcomputer_kid
Jan 3 at 10:17
withoutsupportsRtl
not possible
– Sniffer
Jan 3 at 10:20
thanks, but as i mentioned before. this way need very long code. But is there really no other way to do this?
– danial abadi ghadim
Jan 3 at 10:24
|
show 3 more comments
sorry for my bad English.
I have a navigation drawer in some activities, I want the icon of each navigation view item to be placed to the right of that item's text and the whole item get right gravity.
Because I only used Persian in my app, I can not use "supportsRtl" in my code, if I use, it will look weird when I set device language to any rtl languages.
I think probably I can fix this with setting custom layout for navigation view, but I'm looking for a simpler way. this is my NavigationView XML code:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layout_gravity="end" />
Edited :
layoutDirection is a good answer but i used drawerLayout.openDrawer(GravityCompat.START);
for opening navigation drawer. now if device language be an rtl language this make app crash.
android navigation-drawer rtl-language
sorry for my bad English.
I have a navigation drawer in some activities, I want the icon of each navigation view item to be placed to the right of that item's text and the whole item get right gravity.
Because I only used Persian in my app, I can not use "supportsRtl" in my code, if I use, it will look weird when I set device language to any rtl languages.
I think probably I can fix this with setting custom layout for navigation view, but I'm looking for a simpler way. this is my NavigationView XML code:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layout_gravity="end" />
Edited :
layoutDirection is a good answer but i used drawerLayout.openDrawer(GravityCompat.START);
for opening navigation drawer. now if device language be an rtl language this make app crash.
android navigation-drawer rtl-language
android navigation-drawer rtl-language
edited Jan 3 at 10:41
danial abadi ghadim
asked Jan 3 at 10:04
danial abadi ghadimdanial abadi ghadim
205
205
Try to add Custom Listview or RecylerView in Navigation drawer
– Sniffer
Jan 3 at 10:08
thanks, it is a good way but in that case i will need a layout for item and an adapter class ,... . my code will become very longer only for solving this rtl problem . i'm looking for a simpler way or an custom library for it.
– danial abadi ghadim
Jan 3 at 10:16
This might help stackoverflow.com/questions/33464416/…
– okcomputer_kid
Jan 3 at 10:17
withoutsupportsRtl
not possible
– Sniffer
Jan 3 at 10:20
thanks, but as i mentioned before. this way need very long code. But is there really no other way to do this?
– danial abadi ghadim
Jan 3 at 10:24
|
show 3 more comments
Try to add Custom Listview or RecylerView in Navigation drawer
– Sniffer
Jan 3 at 10:08
thanks, it is a good way but in that case i will need a layout for item and an adapter class ,... . my code will become very longer only for solving this rtl problem . i'm looking for a simpler way or an custom library for it.
– danial abadi ghadim
Jan 3 at 10:16
This might help stackoverflow.com/questions/33464416/…
– okcomputer_kid
Jan 3 at 10:17
withoutsupportsRtl
not possible
– Sniffer
Jan 3 at 10:20
thanks, but as i mentioned before. this way need very long code. But is there really no other way to do this?
– danial abadi ghadim
Jan 3 at 10:24
Try to add Custom Listview or RecylerView in Navigation drawer
– Sniffer
Jan 3 at 10:08
Try to add Custom Listview or RecylerView in Navigation drawer
– Sniffer
Jan 3 at 10:08
thanks, it is a good way but in that case i will need a layout for item and an adapter class ,... . my code will become very longer only for solving this rtl problem . i'm looking for a simpler way or an custom library for it.
– danial abadi ghadim
Jan 3 at 10:16
thanks, it is a good way but in that case i will need a layout for item and an adapter class ,... . my code will become very longer only for solving this rtl problem . i'm looking for a simpler way or an custom library for it.
– danial abadi ghadim
Jan 3 at 10:16
This might help stackoverflow.com/questions/33464416/…
– okcomputer_kid
Jan 3 at 10:17
This might help stackoverflow.com/questions/33464416/…
– okcomputer_kid
Jan 3 at 10:17
without
supportsRtl
not possible– Sniffer
Jan 3 at 10:20
without
supportsRtl
not possible– Sniffer
Jan 3 at 10:20
thanks, but as i mentioned before. this way need very long code. But is there really no other way to do this?
– danial abadi ghadim
Jan 3 at 10:24
thanks, but as i mentioned before. this way need very long code. But is there really no other way to do this?
– danial abadi ghadim
Jan 3 at 10:24
|
show 3 more comments
2 Answers
2
active
oldest
votes
Make supportsRtl true and set the layout dirction to RTL on navigation View and LTR in other layouts
layout direction is a good answer but i used drawerLayout.openDrawer(GravityCompat.START); for opening navigation drawer. now if device language be an rtl language this make app crash. can i handle it with some solution?
– danial abadi ghadim
Jan 3 at 10:43
Try change start to right
– Billel Arfi
Jan 3 at 11:04
thanks for your answer, i used gravityCompat.start but i must use Gravity.Right instead.
– danial abadi ghadim
Jan 3 at 11:25
You are welcome
– Billel Arfi
Jan 3 at 12:31
add a comment |
Just add android:layoutDirection="rtl"
to your NavigationView
, like this:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layoutDirection="rtl"
android:layout_gravity="end" />
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f54020035%2fdisplay-the-icon-at-the-right-of-the-text-in-navigation-view%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Make supportsRtl true and set the layout dirction to RTL on navigation View and LTR in other layouts
layout direction is a good answer but i used drawerLayout.openDrawer(GravityCompat.START); for opening navigation drawer. now if device language be an rtl language this make app crash. can i handle it with some solution?
– danial abadi ghadim
Jan 3 at 10:43
Try change start to right
– Billel Arfi
Jan 3 at 11:04
thanks for your answer, i used gravityCompat.start but i must use Gravity.Right instead.
– danial abadi ghadim
Jan 3 at 11:25
You are welcome
– Billel Arfi
Jan 3 at 12:31
add a comment |
Make supportsRtl true and set the layout dirction to RTL on navigation View and LTR in other layouts
layout direction is a good answer but i used drawerLayout.openDrawer(GravityCompat.START); for opening navigation drawer. now if device language be an rtl language this make app crash. can i handle it with some solution?
– danial abadi ghadim
Jan 3 at 10:43
Try change start to right
– Billel Arfi
Jan 3 at 11:04
thanks for your answer, i used gravityCompat.start but i must use Gravity.Right instead.
– danial abadi ghadim
Jan 3 at 11:25
You are welcome
– Billel Arfi
Jan 3 at 12:31
add a comment |
Make supportsRtl true and set the layout dirction to RTL on navigation View and LTR in other layouts
Make supportsRtl true and set the layout dirction to RTL on navigation View and LTR in other layouts
answered Jan 3 at 10:26
Billel ArfiBillel Arfi
639
639
layout direction is a good answer but i used drawerLayout.openDrawer(GravityCompat.START); for opening navigation drawer. now if device language be an rtl language this make app crash. can i handle it with some solution?
– danial abadi ghadim
Jan 3 at 10:43
Try change start to right
– Billel Arfi
Jan 3 at 11:04
thanks for your answer, i used gravityCompat.start but i must use Gravity.Right instead.
– danial abadi ghadim
Jan 3 at 11:25
You are welcome
– Billel Arfi
Jan 3 at 12:31
add a comment |
layout direction is a good answer but i used drawerLayout.openDrawer(GravityCompat.START); for opening navigation drawer. now if device language be an rtl language this make app crash. can i handle it with some solution?
– danial abadi ghadim
Jan 3 at 10:43
Try change start to right
– Billel Arfi
Jan 3 at 11:04
thanks for your answer, i used gravityCompat.start but i must use Gravity.Right instead.
– danial abadi ghadim
Jan 3 at 11:25
You are welcome
– Billel Arfi
Jan 3 at 12:31
layout direction is a good answer but i used drawerLayout.openDrawer(GravityCompat.START); for opening navigation drawer. now if device language be an rtl language this make app crash. can i handle it with some solution?
– danial abadi ghadim
Jan 3 at 10:43
layout direction is a good answer but i used drawerLayout.openDrawer(GravityCompat.START); for opening navigation drawer. now if device language be an rtl language this make app crash. can i handle it with some solution?
– danial abadi ghadim
Jan 3 at 10:43
Try change start to right
– Billel Arfi
Jan 3 at 11:04
Try change start to right
– Billel Arfi
Jan 3 at 11:04
thanks for your answer, i used gravityCompat.start but i must use Gravity.Right instead.
– danial abadi ghadim
Jan 3 at 11:25
thanks for your answer, i used gravityCompat.start but i must use Gravity.Right instead.
– danial abadi ghadim
Jan 3 at 11:25
You are welcome
– Billel Arfi
Jan 3 at 12:31
You are welcome
– Billel Arfi
Jan 3 at 12:31
add a comment |
Just add android:layoutDirection="rtl"
to your NavigationView
, like this:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layoutDirection="rtl"
android:layout_gravity="end" />
add a comment |
Just add android:layoutDirection="rtl"
to your NavigationView
, like this:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layoutDirection="rtl"
android:layout_gravity="end" />
add a comment |
Just add android:layoutDirection="rtl"
to your NavigationView
, like this:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layoutDirection="rtl"
android:layout_gravity="end" />
Just add android:layoutDirection="rtl"
to your NavigationView
, like this:
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="@menu/menu"
android:layoutDirection="rtl"
android:layout_gravity="end" />
answered Jan 3 at 10:33
Alexey DenysenkoAlexey Denysenko
1,8801821
1,8801821
add a comment |
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.
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%2f54020035%2fdisplay-the-icon-at-the-right-of-the-text-in-navigation-view%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
Try to add Custom Listview or RecylerView in Navigation drawer
– Sniffer
Jan 3 at 10:08
thanks, it is a good way but in that case i will need a layout for item and an adapter class ,... . my code will become very longer only for solving this rtl problem . i'm looking for a simpler way or an custom library for it.
– danial abadi ghadim
Jan 3 at 10:16
This might help stackoverflow.com/questions/33464416/…
– okcomputer_kid
Jan 3 at 10:17
without
supportsRtl
not possible– Sniffer
Jan 3 at 10:20
thanks, but as i mentioned before. this way need very long code. But is there really no other way to do this?
– danial abadi ghadim
Jan 3 at 10:24