zoukankan      html  css  js  c++  java
  • AppCompatActivity

    https://segmentfault.com/a/1190000002702843

    构建一个可以跑在不同版本 Android 平台的软件,是非常复杂和耗时的。为了解决这个问题,Android 推出了 Android Support Library (安卓兼容包),让新的UI控件也可以跑在早期的 Android 版本。最近Android Support Library 更新到v22.1,这一版本主要AppCompat做了一些大的调整。

    重构AppCompat

    初期AppCompat只是让Actionbar兼容到API 7。在AppCompat 21版本中,加入主题色、Toolbar等功能。显然ActionBarActivity这个名字已经不在适用AppCompat。新版本中,推荐使用AppCompatActivity 代替ActionBarActivity。

    android:theme

    新版本AppCompat 允许对 Toolbar 使用 android:theme代替 app:theme. 兼容 API11+.

     <android.support.v7.widget.Toolbar
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/main_drawer_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_below="@+id/main_statusBar"
                    android:background="?attr/colorPrimary"
                    android:translationZ="4dp"
                    android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
    
    

    AppCompatDialog对话框

    终于加入MD对话框和新主题theme Theme.AppCompat.Dialog
    使用

      AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Dialog");
            builder.setMessage("少数派客户端");
            builder.setPositiveButton("OK", null);
            builder.setNegativeButton("Cancel", null);
            builder.show();
    

    具体效果

  • 相关阅读:
    .Net Core Swagger配置
    MySQL如何使用索引
    一个HTTP Basic Authentication引发的异常
    跑步花钱吗?
    跑步花钱吗?
    OpenShift中的持续交付
    在AWS中部署OpenShift平台
    壮美大山包-2017中国大山包国际超百公里ITRA积分赛赛记
    膝盖中了一箭之康复篇-两周年纪念
    HashiCorp Vault介绍
  • 原文地址:https://www.cnblogs.com/liangouyang/p/5408600.html
Copyright © 2011-2022 走看看