Hello, I'm a beginner who is developing an app with Android Studio.
Similar to the picture, we implemented a tab bar with letters under the icon &
Like the picture above, I want to change the color that I specified when I selected one tab. Unselected tabs remain in their first color. Currently, only the underlined bar below the icon changes color when selecting a tab. Where and what coding should I do to make it possible?ㅠ<
android java
Try the selector. Below is an example of an Android reference document.
button.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/button_pressed" /> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/button_focused" /> <!-- focused -->
<item android:state_hovered="true"
android:drawable="@drawable/button_focused" /> <!-- hovered -->
<item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/button" />
Make two images for each. You can change it.
© 2024 OneMinuteCode. All rights reserved.