问题
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