I'd like to add a color to the title of the top bar like the list of friends on Kakao Talk.

Asked 2 years ago, Updated 2 years ago, 123 views

1 If you look at this picture, there's a 4,129 friend on the top bar and a button on the right. I want to give 4,129 and 4,129 different handwriting colors What can I do?

android actionbar title

2022-09-22 10:15

1 Answers

I think you can register a custom layout on the action bar. I did it like this.

custom_layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_centerVertical="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Invite"
        android:textSize="25sp"/>
    <TextView
        android:layout_centerVertical="true"
        android:id="@+id/invite"
        android:layout_marginLeft="62dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0"
        android:textSize="22sp"
        android:textColor="#000000"/>
</RelativeLayout>
         ActionBar mActionBar = getActionBar();
        mActionBar.setDisplayShowHomeEnabled(false);
        mActionBar.setDisplayShowTitleEnabled(false);
        LayoutInflater mInflater = LayoutInflater.from(this);

        View mCustomView = mInflater.inflate(R.layout.custom_layout, null);

        mActionBar.setCustomView(mCustomView);
        mActionBar.setDisplayShowCustomEnabled(true);


2022-09-22 10:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.