android place a textview over application title

我的梦境 提交于 2019-12-14 03:32:02

问题


Is it possible to place a textbox over the application title bar? like in xcode, it is possible to place a textbox anywhere I guess using absolute positioning...

The aim is to put a small version indicator on the top right corner of the application title bar.

Thanks


回答1:


Please try with the below one.

 @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");
        }


    }


来源:https://stackoverflow.com/questions/31646210/android-place-a-textview-over-application-title

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!