I was also struggling with this issue. I ended up inflating the Toolbar and adding it to the root layout (https://stackoverflow.com/a/27455330/1889752).
PreferenceActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
LinearLayout linearLayout = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
Toolbar toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.tool_bar, linearLayout, false);
toolbar.setTitle(getString(R.string.settings_header_title));
linearLayout.addView(toolbar, 0);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
overridePendingTransition(0,0);
finish();
}
});
}
activity_settings.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
tool_bar.xml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/blue"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:navigationIcon="?attr/homeAsUpIndicator">
You should have a look at the AppCompatPreferenceActivity