C
C
Chvalov2015-08-28 11:08:19
Android
Chvalov, 2015-08-28 11:08:19

Is it possible to write your own text to the right of the name of the program in Android?

I don't know exactly what it's called, but probably ActionBar
Where AndroidBattery is written : AndroidBattery_2.png
Is it possible to display your text to the right of the program name?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Emin, 2015-08-28
@Ewintory

We continue yesterday's relay?) Activity#setTitle("AndroidBattery: Some text")as an option.
Or for example

<activity
            android:name=".ui.activity.AboutActivity"
            android:label="AndroidBattery: Some text"
            android:parentActivityName=".ui.activity.HomeActivity" />

A
Andrey, 2015-08-28
@kozinakoff

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="match_parent">

    <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.Toolbar.Title"
            />

    <TextView
            android:id="@+id/additional_info"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.Toolbar.SubTitle"
            />

</LinearLayout>

In code:
protected Toolbar mToolbar;
        protected TextView mToolbarTitle;
        protected TextView mToolbarSubTitle;

...

        View statusContainer = LayoutInflater.from(this).inflate(R.layout.actionbar_status, mToolbar, false);
        ActionBar.LayoutParams lp = new ActionBar.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        mToolbar.addView(statusContainer, lp);

        mToolbarTitle = (TextView) statusContainer.findViewById(R.id.title);
        mToolbarSubTitle = (TextView) statusContainer.findViewById(R.id.subTitle);

        mToolbarTitle.setText("Какой-то заголовок");
        mToolbarSubTitle.setText("Какой-то дополнительный текст");

Accordingly, you can change the title anywhere (mToolbarSubTitle.setText("Some additional text")), color, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question