I try to built a preference screen with a toolbar, but I got some issues:
Here is the code of my activity_settings.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="@string/action_settings"
android:theme="@style/ThemeOverlay.AppCompat.Dark" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar" />
</LinearLayout>
This is the AndroidManifest entry:
<activity
android:name=".activities.SettingsActivity"
android:label="@string/activity_settings"
android:theme="@style/AppTheme.NoActionBar" />
Can anybody help me?
Add android:layout_marginTop="?attr/actionBarSize"
to your ListView in the xml.
Replace fill_parent
with match_parent
it's deprecated. Remove android:layout_below="@+id/toolbar"
it's not working in LinearLayout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.