`
敲敲大葱头
  • 浏览: 29408 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ViewGroup.LayoutParams的FILL_PARENT与MATCH_PARENT两个常量

阅读更多

常听到有人把LayoutParams的这两个常量给说成不同,乃至有一阵我甚至认为之前看过的api被我记混了。

今天复习的时候,又想起这个问题,于是把API搬出来,告之自己就是相同的。


1. FILL_PARENT与MATCH_PARENT的数值相同

Constant Value: -1 (0xffffffff)

2.  FILL_PARENT在API里已注明:This value is deprecated starting in API Level 8 and replaced by MATCH_PARENT.

3.原因:不得而知,有说是因为Google考虑抄袭java代码的问题,有说是因为大神觉得这个match比fill更贴切


总之,这两个常量现在看来,一个是API8之前的一个是API8之后推荐的。

 

分享到:
评论

相关推荐

    Android代码-安卓新手引导图引导蒙层

    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); iv.setLayoutParams(params); *使用文字 TextView iv = new TextView(this); iv.setText("欢迎使用"); iv.setTextColor(get...

    WindowManager属性详解

    WindowManager属性详解:WindowManager.LayoutParams 是 WindowManager 接口的嵌套类;继承于 ViewGroup.LayoutParams 。 它的内容十分丰富。其实WindowManager.java的主要内容就是由这个类定义构成。

    android.service.java

    params.width = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;// 窗口宽度 params.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;// 窗口高度 manager.addView(layout, params); }

    YCRedDotView-自定义红点控件,不用修改之前的代码,完全解耦,即可以设置红点数字控件,使用十分方便。可以支持设置在TextView,Button,LinearLayout,RelativeLayout,TabLayout等等控件上…….zip

     ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));  parentContainer.addView(badgeContainer, groupIndex, parentLayoutParams);  badgeContainer.addView(view);  ...

    代码动态设置view或布局的宽高

    然而这时候你一定要注意强制类型转换时的LayoutParams类型,因为android中存在3种LayoutParams,即RelativeLayout.LayoutParams、LinearLayout.LayoutParams、ViewGroup.LayoutParams,那么我们改用哪一个呢?...

    android点餐系统 部分功能源代码

    import android.view.ViewGroup.LayoutParams; import android.widget.AdapterView; import android.widget.Button; import android.widget.GridView; import android.widget.ImageView; import android.widget....

    package com.example.f1_telephone;

    String ContactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); Cursor phone = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract....

    ViewPagerFragment滑动切换

    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mTabImg .getLayoutParams(); int[] location = new int[2]; mTab1.getLocationInWindow(location); int marginLeft = (displayWidth ...

    android各组件详解- ViewGroup.pdf

    android各组件详解- ViewGroup.pdf

    android顶部滑动导航

    import android.view.ViewGroup.LayoutParams; import android.view.animation.LinearInterpolator; import android.view.animation.TranslateAnimation; import android.widget.HorizontalScrollView; import ...

    Android 悬浮窗功能实现(微信语音通话悬浮窗效果实现)

    目录 1.基本介绍 2.代码示例 3.实现效果及便捷工具类 4.仿微信语音通话悬浮窗效果实现 ...addView(View view, ViewGroup.LayoutParams params) 主要通过该方法将指定 View 添加到屏幕上,实现悬浮窗效果 ( WindowMan

    从源码解析Android中View的容器ViewGroup

    这回我们是深入到ViewGroup内部\,了解ViewGroup的工作...在这个类里定义了ViewGroup.LayoutParams类,这个类是布局参数的子类。  其实ViewGroup也就是View的容器。通过ViewGroup.LayoutParams来指定子View的参数。 V

    LCRapidDevelop-master

    android:layout_height="match_parent"> android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <!--SpringView下拉刷新--> <com.xiaochao....

    Android 让按钮随着触控笔的移动一起移动.rar

      ViewGroup.LayoutParams lp=  new AbsoluteLayout.LayoutParams(   WRAP_CONTENT, WRAP_CONTENT,   (int)event.getRawX()-xSpan-X_MODIFY,   (int)event.getRawY()-ySpan-Y_MODIFY  ) ;

    android 的类似于QQ分组的二级列表

    ViewGroup.LayoutParams.MATCH_PARENT, 64); TextView textView = new TextView(ExpandableListDemo.this); textView.setLayoutParams(lp); // Center the text vertically textView.setGravity(Gravity....

    布局组建layout

    ViewGroup中,还定义了一个嵌套类ViewGroup.LayoutParams。这个类定义了一个显示对象的位置、大小等属性,view通过LayoutParams中的这些属性值来告之父级,它们将如何放置。 ViewGroup是一个抽象类,所以真正充当...

    SwipeMenuViewHolder:一个可以滑出条目操作菜单的RecycleView.ViewHolder

    SwipeMenuViewHolder一个可以滑出条目操作菜单的RecycleView.ViewHolder 。...View swipeMenuView = layoutInflater...swipeMenuView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, V

    仿ireader书架

    public View getView ( int position , View convertView , ViewGroup parent ) { LayoutInflater layout_inflater = ( LayoutInflater ) ReaderActivity.this.getSystemService ( Context.LAYOUT_INFLATER_...

    SwipeListViewTest项目

    下面两个表示向左或者向右滑动时的偏移量,一般不在xml文件中设置,而是在代码中根据设置的大小来设置偏移量。 swipe:swipeOffsetLeft=”0dp” swipe:swipeOffsetRight=”0dp” 再来看看Item布局文件,这里包括...

Global site tag (gtag.js) - Google Analytics