asdsolutions-os / duo-navigation-drawer

A flexible, easy to use, unique drawer library for your Android project.
http://psdcompany.nl/
Apache License 2.0
1.1k stars 191 forks source link

how to chnag text color in menu #41

Open yasirabid96 opened 4 years ago

arslan555 commented 4 years ago

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

FaridBen95 commented 4 years ago

@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

Hamza417 commented 4 years ago

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