Android编程入门--android.support.v7.widget.Toolbar

参考博客:利用 v7 Toolbar 自定义 Android ActionBar

布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.zyp.driot.TimerChartActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.NoActionBar.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.NoActionBar.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_timer_chart" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="64dp"
        android:src="@android:drawable/stat_notify_sync" />

</android.support.design.widget.CoordinatorLayout>

manifest

            android:name=".ui.activity.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">

注:android:fitsSystemWindows="true"

需要CoordinatorLayout作为主布局容器

代码

    @BindView(R.id.toolbar)
    Toolbar mToolBar;

        setSupportActionBar(mToolBar);
时间: 2024-08-26 06:47:55

Android编程入门--android.support.v7.widget.Toolbar的相关文章

android.support.v7.widget.Toolbar找不到

今天下了个demo,打开找不到android.support.v7.widget.Toolbar 明明已经引用了appcompat_v7了?并且出现了ActionBarActivity cannot be resolved to a type错误? 解决:确保导入最新的appcompat_v7库,导入后该库可能出现xml文件错误,不要着急,把该库的android sdk版本改为5.0以上即可,clean一下就好了:然后修改项目的android版本也为5.0以上. 上传了最新了最新的appcomp

android.support.v7.widget.Toolbar 中menu图标不显示问题

<?xml version="1.0" encoding="utf-8"?><menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_yybs_sea

Android编程入门--android 7.0 的so文件

参考博客:android 7.0对开发者会有哪些影响 参考博客:android 7.0 因为.so文件而崩溃事件解决 由于调用系统so出错 将系统so拷贝出来使用即可.

int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType&#39; on a null.....

Android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null..空指针问题,费劲心思才找到报空指针的原因: 代码是这样的,有多种布局类型 @Override public int getItemViewType(int position) { BmobIMMessage message = msgs.get(position); if(message.getMsgType().equals(BmobIMMes

The following classes could not be instantiated: android.support.v7.widget.ActionBarOverLayLayout

今天用android studio新建了个项目,当展示xml文件的时候,提示The following classes could not be instantiated: android.support.v7.widget.ActionBarOverLayLayout. 在stackoverflow查了查,解决方案如图所示:

android.support.v7.widget.SearchView 修改字体颜色

问题描述:在v4扩展包下的searchView网上通常采用  int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);  TextView textView = (TextView) searchView.findViewById(id);  textView.setTextColor(Color.WHITE);来改变字体颜色,但是在v

007. 使用百度地图SDK时有如下报错:Could not find class &#39;android.graphics.drawable.RippleDrawable&#39;, referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

问题描述:Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering,除了以上报错,还有其他相关报错,could not find class/method XXXX 007. 使用百度地图SDK时有如下报错:Could not find c

Android编程入门--RecyclerView使用

布局 <android.support.v7.widget.RecyclerView android:id="@+id/rv_department" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false" android:clipToPadding="false&q

《Delphi XE6 android 编程入门教程》推荐

近5.6已经没有看见关于delphi的新技术的书出来了(看来在国内delphi的使用量确实很低了), 高勇同学最近出了一本<Delphi XE6 android 编程入门教程>,上周刚拿到,这一周大概看了一遍. 严格意义上,这本书不是按正常的出版的格式来的,大部分应该是类似博客的汇总.delphi 开发android 还是一个新事物,也就是去年才开始,相关资料也是少之甚少,这么短的的时间,能汇总出出这么高质量的资料, 先谢谢高勇同学能花这么多业余时间完成这么一项艰巨的任务. 首先,这本书主要介