0

I am trying to implement a footer similar to youtube APP. When I click one of the icons in youtube App footer. The icon changes to red.

youtube snapshot

What is the best way to implement this? Is there a ways to implement using <selector xmlns:android="http://schemas.android.com/apk/res/android"> in drawable folder

or I have to implement this programmatically. if so I have to put a lot of conditions. I tried the following.

if (homeclicked) {
    ImageView homeImage = (ImageView) findViewById(R.id.homeImage);
    homeImage.setImageResource(R.drawable.ic_home_orange);

    TextView homeText = (TextView) findViewById(R.id.homeText);
    homeText.setTypeface(tf3);
    homeText.setTextColor(getResources().getColor(R.color.orangecolor));
}
else {
    ImageView homeImage = (ImageView) findViewById(R.id.homeImage);
    homeImage.setImageResource(R.drawable.ic_home);

    TextView homeText = (TextView) findViewById(R.id.homeText);
    homeText.setTypeface(tf3);
    homeText.setTextColor(getResources().getColor(R.color.white));
}

homeclicked = !homeclicked;

I will have to change other icons in the footer accordingly.

I felt the best way is to use pressed, onfocus in selector method in XML drawable but how to change icon and text color when clicking it.

Can someone help me with this?

beeb
  • 1,615
  • 1
  • 12
  • 24
RAMKUMAR
  • 17
  • 5

0 Answers0