duo-navigation-drawer icon indicating copy to clipboard operation
duo-navigation-drawer copied to clipboard

how to chnag text color in menu

Open yasirabid96 opened this issue 5 years ago • 3 comments

yasirabid96 avatar Jan 31 '20 19:01 yasirabid96

Still looking for it @yasirabid96. Do you find any solution.

arslan555 avatar Apr 07 '20 18:04 arslan555

@arslan555 @arslan555 create a class that extends from DuoOptionView copy the code from DuoOptionView to your class copy the ressource file from duo_view_option to a new ressource file remove the text and change the text color in the text view change the layout in the class to your new ressource file set the text color in the constructor of OptionViewHolder and then use your customeDuoOptionView class instead of DuoOptionView inside your adapter

FaridBen95 avatar May 27 '20 14:05 FaridBen95

Just go to your MenuAdapter, find the view like this

TextView textView = optionView.getRootView().findViewById(R.id.duo_view_option_text);

then set the text color

textView.setTextColor(Color.BLACK);

you can do the same with the dots as well,

ImageView imageView = optionView.getRootView().findViewById(R.id.duo_view_option_selector);

// Create your own shape drawable for the dot first, then set it like this
imageView.setImageResource(R.drawable.ic_circle);

for reference, you getView should look like this

@Override
   public View getView(int position, View convertView, ViewGroup parent) {
       final String option = mOptions.get(position);
       
       // Using the DuoOptionView to easily recreate the demo
       final DuoOptionView optionView;
       if (convertView == null) {
           optionView = new DuoOptionView(parent.getContext());
       } else {
           optionView = (DuoOptionView) convertView;
       }
       
       TextView textView = optionView.getRootView().findViewById(R.id.duo_view_option_text);
       textView.setTextColor(Color.BLACK);
   
       ImageView imageView = optionView.getRootView().findViewById(R.id.duo_view_option_selector);
       imageView.setImageResource(R.drawable.ic_circle);
       
       // Using the DuoOptionView's default selectors
       optionView.bind(option, null, null);
       
       // Adding the views to an array list to handle view selection
       mOptionViews.add(optionView);
       
       return optionView;
   }

Not sure its the best way but it works right now

Hamza417 avatar Oct 27 '20 15:10 Hamza417