Androidde Custom Title Ekleme

Bunu runtime da yapabiliyoruz. On create içerisinde :

 

java kodu

@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature( Window.FEATURE_CUSTOM_TITLE );
setContentView(R.layout.activity_intro);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
super.onCreate(savedInstanceState);

//some code maybe
TextView headerText = (TextView) findViewById(R.id.custom_title_text);
headerText.setText(“Tamir Atölyesi”);
headerText.postInvalidate();
}

 

title olarak ekleyeceğimiz layout :

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:gravity=”left”
android:orientation=”horizontal” >
<TextView
android:id=”@+id/custom_title_text”
android:layout_height=”wrap_content”
android:layout_width=”fill_parent”/>
</LinearLayout>