zoukankan      html  css  js  c++  java
  • android小知识

    1.获得rootView

    (1)在activity中根据android.R.id.content

    (2)View.getRootView()

    (3)getWindow().getDecorView().findViewById(android.R.id.content)

    2.通过setDisplayOptions (int options, int mask)  可设置ActionBar的显示选项。

    ActionBar.DISPLAY_HOME_AS_UP      在ActionBar左边显示'<'图标,在应用中可以通过点击此图标回到应用的主页。

    ActionBar.DISPLAY_SHOW_HOME      在ActionBar左边显示Home图标,就是此应用的icon图标,点击它也可以返回到首页。

    ActionBar.DISPLAY_USE_LOGO           在Home图标的位置显示我们设置的logo图标,Activity的android:logo属性

    ActionBar.DISPLAY_SHOW_TITLE       显示图标后面的标题名称,Activity的android:lable属性

    ActionBar.DISPLAY_SHOW_CUSTOM      显示通过setCustomView添加到ActionBar的自定义View

    ActionBar.NAVIGATION_MODE_TABS    显示我们添加到ActionBar的Tab

    例如:与运算:一一得一。

    setDisplayOptions(0, DISPLAY_SHOW_HOME) will disable the DISPLAY_SHOW_HOME option.

    setDisplayOptions(DISPLAY_SHOW_HOME, DISPLAY_SHOW_HOME | DISPLAY_USE_LOGO) will enable DISPLAY_SHOW_HOME and disable DISPLAY_USE_LOGO.

    3.style和theme的原文件可以在<ANDROID_SDK_HOME>/platforms/android-15/data/res/values/下面找到

    其中styles.xml和theme.xml文件就是R.style类的定义文件

    4.使用style时@与?的区别

    android:textAppearance="@andorid:style/TextAppearance.Medium", 

    android:textAppearance="?android:attr/textAppearanceMedium"

    使用@表示使用固定的style,而不会跟随Theme改变,这个style可以在style.xml中找到。而?表示从Theme中查找引用的资源名

    例如上面的textAppearanceMedium,查看themes.xml文件,可以看到在不同的theme中,textAppearanceMedium引用的style是不同的。

    如在Them.Holo中

      <item name="textAppearanceMedium">@android:style/TextAppearance.Holo.Medium</item>

    Theme.Holo.Light中

      <item name="textAppearanceMedium">@android:style/TextAppearance.Holo.Light.Medium</item>

    5.android:descendantFocusability 解决不调用onListItemClick(ListView l, View v, int position, long id)问题

            beforeDescendants:The ViewGroup will get focus before any of its descendants. viewgroup会优先其子类控件而获取到焦点

            afterDescendants:The ViewGroup will get focus only if none of its descendants want it. viewgroup只有当其子类控件不需要获取焦点时才获取焦点

            blocksDescendants:The ViewGroup will block its descendants from receiving focus. viewgroup会阻碍子类控件而直接获得焦点(常用)

     

  • 相关阅读:
    QT槽和信号机制介绍
    J2EE面试题之二
    .net 面试题系列文章一(附答案)
    SUN JAVA面试笔试题
    用友在清华的笔试题
    Java面试笔试题整理
    雅虎公司C#笔试题(之一)
    Oracle面试题及答案整理
    一些著名的大公司JAVA面试题目
    百度技术研发笔试题目1
  • 原文地址:https://www.cnblogs.com/yuyutianxia/p/3496678.html
Copyright © 2011-2022 走看看