Android 探究 LayoutInflater setFactory文章的补充
来源:互联网 发布:蝎子网络第二季5 编辑:程序博客网 时间:2024/05/16 17:55
compile 'com.android.support:support-v4:22.2.1' compile 'com.android.support:appcompat-v7:22.2.1'
在文件AppCompatDelegateImplV7.java中有
@Override public View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs) { final boolean isPre21 = Build.VERSION.SDK_INT < 21; if (mAppCompatViewInflater == null) { mAppCompatViewInflater = new AppCompatViewInflater(); } // We only want the View to inherit it's context if we're running pre-v21 and... final boolean inheritContext = isPre21 && mSubDecorInstalled && parent != null // We do not want to inherit context from any decor content && parent.getId() != android.R.id.content // We do not want to inherit context if this is the root view in the layout. // We use parent.isAttachedToWindow() to determine this, which works because // an inflated layout is only added to the hierarchy AFTER it is completely // inflated. Thus isAttachedToWindow() will only return true if the parent // has not been inflated within the outer inflation call. && !ViewCompat.isAttachedToWindow(parent); return mAppCompatViewInflater.createView(parent, name, context, attrs, inheritContext, isPre21, /* Only read android:theme pre-L (L+ handles this anyway) */ true /* Read read app:theme as a fallback at all times for legacy reasons */ ); }
public final View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs, boolean inheritContext, boolean readAndroidTheme, boolean readAppTheme) { final Context originalContext = context; // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy // by using the parent's context if (inheritContext && parent != null) { context = parent.getContext(); } if (readAndroidTheme || readAppTheme) { // We then apply the theme on the context, if specified context = themifyContext(context, attrs, readAndroidTheme, readAppTheme); } // We need to 'inject' our tint aware Views in place of the standard framework versions switch (name) { case "EditText": return new AppCompatEditText(context, attrs); case "Spinner": return new AppCompatSpinner(context, attrs); case "CheckBox": return new AppCompatCheckBox(context, attrs); case "RadioButton": return new AppCompatRadioButton(context, attrs); case "CheckedTextView": return new AppCompatCheckedTextView(context, attrs); case "AutoCompleteTextView": return new AppCompatAutoCompleteTextView(context, attrs); case "MultiAutoCompleteTextView": return new AppCompatMultiAutoCompleteTextView(context, attrs); case "RatingBar": return new AppCompatRatingBar(context, attrs); case "Button": return new AppCompatButton(context, attrs); case "TextView": return new AppCompatTextView(context, attrs); } if (originalContext != context) { // If the original context does not equal our themed context, then we need to manually // inflate it using the name so that android:theme takes effect. return createViewFromTag(context, name, attrs); } return null; }
注意:在最新的
compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0'却没有相关的AppCompatViewInflater.java文件。
参考文章:http://blog.csdn.net/lmj623565791/article/details/51503977
0 0
- Android 探究 LayoutInflater setFactory文章的补充
- Android 探究 LayoutInflater setFactory
- Android 探究 LayoutInflater setFactory
- Android 探究 LayoutInflater setFactory
- Android 探究 LayoutInflater setFactory
- Android 探究 LayoutInflater setFactory
- Android探究之LayoutInflater setFactory
- Android中LayoutInflater.setFactory的初步认识!
- android之LayoutInflater以及setFactory源码解读
- 探究LayoutInflater的inflate()方法
- Android LayoutInflate.SetFactory( )(三)
- 菜单文章的补充
- 【LayoutInflater】Android 中LayoutInflater的使用!
- android LayoutInflater的使用
- Android - LayoutInflater 的使用
- Android 的 LayoutInflater
- Android LayoutInflater的用法
- Android LayoutInflater的使用
- MyBatis动态参数为数组、list、Map,并使用oder by给结果排序
- PHP框架一:Smarty视图引擎
- JAVA STRING
- 历史收集
- [leetcode] 128. Longest Consecutive Sequence
- Android 探究 LayoutInflater setFactory文章的补充
- Ubuntu 14.04编译RT288x_SDK/toolchain/squashfs3.2-r2时出错
- TabHost控件应用
- 判断手机号的输入是否正确、获取当前的时间以及显示距离上次发布有多久的时间
- IOS开发 Xcode7.3不能提示自定义类名问题解决办法
- ListView的使用
- Lua内存泄露情况举例
- Qt Creator中添加菜单栏实例
- 第一个程序