Android 同一个标题栏应用不同风格的标题

Android application different style titles in same title bar

我有一个应用程序,要求在应用程序标题栏的右上角显示应用程序版本名称。

这可能吗?

请注意,版本名称的颜色和大小也不同。

抱歉无法 post 图片,因为声誉不够.... :(

有点像

--------------------------------------------------
Application title comes here...              v1.23
--------------------------------------------------

这似乎是不可能的。

唯一的解决方法似乎是使用此 post android place a textview over application title

中提到的自定义标题栏

下面的代码以获得快速帮助:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

        setContentView(R.layout.main);

        if ( customTitleSupported ) {
            getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
        }

        final TextView myTitleText = (TextView) findViewById(R.id.myTitle);
        if ( myTitleText != null ) {
            myTitleText.setText("MY TITLE");
        }


    }

希望对大家有所帮助!