android


setting background and text color to topmost item in hamburger android


I want to set a black background with a white textview to the topmost item of the hamburger menu.It tried dynamically but setting Menu Item class does not have any propert setBackgroundDrawable etc.This is my menu and I want to set the background to navigation_item_1.pls help me
<?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">
<group android:id="#+id/grp1" android:checkableBehavior="single" >
<item
android:id="#+id/navigation_item_1"
android:checked="true"
android:icon="#drawable/ic_home"
android:title="get i5 Pro" />
</group>
<group android:checkableBehavior="single">
<item
android:id="#+id/home"
android:icon="#drawable/ic_home"
android:title="Home"/>
<item
android:id="#+id/activate_pro"
android:icon="#drawable/ic_pro"
android:title="Active PRO"/>
<item
android:id="#+id/my_music"
android:icon="#drawable/ic_music_list"
android:title="My Music"/>
<item
android:id="#+id/nav_browse"
android:icon="#drawable/ic_brows_black"
android:title="Browse and Discover" />
<item
android:id="#+id/radio_stations"
android:icon="#drawable/ic_radio_station"
android:title="Radio Stations"/>
<item
android:id="#+id/new_releases"
android:icon="#drawable/ic_new_release"
android:title="New Releases"/>
<item
android:id="#+id/my_profile"
android:icon="#drawable/ic_profile"
android:title="My Profile" />
<item
android:id="#+id/music_lang"
android:icon="#drawable/ic_checked"
android:title="Music Languages" />
<item
android:id="#+id/settings"
android:icon="#drawable/ic_settings"
android:title="Settings"/>
<item
android:id="#+id/nav_login"
android:icon="#drawable/ic_logout"
android:title="Log in " />
<item
android:id="#+id/nav_log_out"
android:icon="#drawable/ic_logout"
android:title="Log out " />
</group>
</menu>
In xml file having navigation view add following code inside navigation view as :
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="horizontal"
android:layout_marginTop="330dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/ic_home"/>
<TextView
android:id="#+id/mSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:textColor="#ffffff"
android:text="get i5 Pro" />
</LinearLayout>
</android.support.design.widget.NavigationView>
Where you have to give margin top of linear layout according to your header height.. e.g. If your header height is 320 dp then you need to increase is by 10 dp or more according to your requirement.

Related Links

Custom SurfaceView causing NoSuchMethodException
Edittext jumps to next edittext, but wrong
How do I grant Read/Write Permissions to internal storage of my application to TextToSpeech/MediaPlayer?
Since animation can only be set as background, how to have a background?
how to save application state in android [duplicate]
Android:Sqlite Fatal Exception Main
Writing for multiple resolutions on Android?
How to enable the background data settings in android?
ETC Compress image in Android code?
EditText in dialog android
On second test getActivity() never returns
2 xml android calendar
Android ViewGroup clipping doesn't work
Android browser downloading images automatically
Issue with finding place name using geocoder
Getting a count of the number of sent SMS messages

Categories

HOME
embedded
paraview
github-for-windows
ecmascript-6
youtube-data-api-v3
static
owl-carousel
spring-data-mongodb
teechart
accessibility
spin
fosrestbundle
little-proxy
windows-ce
java.util.logging
emoji
filechannel
automatic-ref-counting
scrolltop
heat
video-editing
digital-signature
sar
cgbitmapcontext
ember-cli
exit
dynamically-generated
ckfinder
nstimer
ms-access-2003
8051
winexe
exchangewebservices
ceylon
paperjs
recurring-events
jmockit
glib
r-grid
autolisp
navigator
protege4
python-pptx
lint
chef-solo
stringtokenizer
congestion-control
xmldocument
dynamic-linq
nanoc
xbmc
textsum
lampp
magento-2.0.7
configurationmanager
geotiff
skin
type-theory
google-photos
juice-ui
microstation
spring-cloud-feign
flex4.6
shopping
http-status-code-401
grass
inf
terracotta
themoviedb-api
rate-limiting
rubaxa-sortable
matlab-deployment
dot.js
procedural-programming
delayed-execution
beatsmusic
punycode
psr-4
create.js
rcaller
authlogic
qscrollarea
high-resolution
isqlquery
cocoalibspotify-2.0
mongohq
scringo
route-provider
cascadingdropdown
subgraph
virtualpathprovider
jquery-address
google-floodlight
svk
presentation-layer
eclipse-marketplace
feasibility
java1.4
wcf-proxy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App