Coder Social home page Coder Social logo

android_action_toolbar's Introduction

android

实习8(1)-Actionbar_Toolbar控件

1) 显示大标题、小标题,Overflow菜单中有三个子菜单。 Done

2) 点击右上侧的overflow图标,菜单显示下下面,不要覆盖Toolbar区域。Done

  1. 设置兼容模式下的app:popupTheme="@style/OverflowMenuStyle"
  2. false
  3. @color/colorPrimary

3) 默认菜单项是不显示图标的,这里要求显示图标。 Done

  1. setOptionalIconsVisible true

4) 要求菜单项的背景颜色和Toolbar的背景颜色是一致的,toolbar上的文字颜色和菜单项的文字颜色是一致的。Done

  1. android:background="?attr/colorPrimary"
  2. android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

5) 点击搜索按钮(放大镜),进入第二个页面。Done

  1. menu item->search
  2. onCreateOptionsMenu getMenuInflater().inflate(R.menu.toolbar, menu)
  3. onOptionsItemSelected

6) 第二个页面中Toolbar左边有一个“上一页”的箭头。点击箭头,回到左边的主页。Done

  1. setDisplayHomeAsUpEnabled true

7) 在介绍ActionBar时,我们介绍了ActionView。请在任一ToolBar上添加一个ActionBar按钮,并完成简单的相应。Done

  1. menu item app:actionViewClass="android.widget.Button"
  2. 加载menu Button btn_test = (Button)menu.findItem(R.id.btn_test).getActionView();
  3. 设置btn_test的内容、字体

思考题:想想怎么让Toolbar中的标题居中显示?Done

  1. 在android.support.v7.widget.Toolbar中套一个TextView 给TextView设置android:layout_gravity="center"
  2. setTitle("")

android_action_toolbar's People

Contributors

duckduckbug avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.