我是靠谱客的博主 执着抽屉,最近开发中收集的这篇文章主要介绍Android R文件分析,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

R文件是在编译资源的时候将工程和包所有的资源文件编译成一个final类,我贴一个简单工程的R文件,以方便大家了解。
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

public final class R {
private R() {
}

public static final class anim {
public static final int abc_fade_in = 2130771968;
public static final int abc_fade_out = 2130771969;
public static final int abc_grow_fade_in_from_bottom = 2130771970;
public static final int abc_popup_enter = 2130771971;
public static final int abc_popup_exit = 2130771972;
public static final int abc_shrink_fade_out_from_bottom = 2130771973;
public static final int abc_slide_in_bottom = 2130771974;
public static final int abc_slide_in_top = 2130771975;
public static final int abc_slide_out_bottom = 2130771976;
public static final int abc_slide_out_top = 2130771977;
public static final int abc_tooltip_enter = 2130771978;
public static final int abc_tooltip_exit = 2130771979;
public static final int btn_checkbox_to_checked_box_inner_merged_animation = 2130771980;
public static final int btn_checkbox_to_checked_box_outer_merged_animation = 2130771981;
public static final int btn_checkbox_to_checked_icon_null_animation = 2130771982;
public static final int btn_checkbox_to_unchecked_box_inner_merged_animation = 2130771983;
public static final int btn_checkbox_to_unchecked_check_path_merged_animation = 2130771984;
public static final int btn_checkbox_to_unchecked_icon_null_animation = 2130771985;
public static final int btn_radio_to_off_mtrl_dot_group_animation = 2130771986;
public static final int btn_radio_to_off_mtrl_ring_outer_animation = 2130771987;
public static final int btn_radio_to_off_mtrl_ring_outer_path_animation = 2130771988;
public static final int btn_radio_to_on_mtrl_dot_group_animation = 2130771989;
public static final int btn_radio_to_on_mtrl_ring_outer_animation = 2130771990;
public static final int btn_radio_to_on_mtrl_ring_outer_path_animation = 2130771991;
public static final int design_bottom_sheet_slide_in = 2130771992;
public static final int design_bottom_sheet_slide_out = 2130771993;
public static final int design_snackbar_in = 2130771994;
public static final int design_snackbar_out = 2130771995;
public static final int fragment_fast_out_extra_slow_in = 2130771996;
public static final int mtrl_bottom_sheet_slide_in = 2130771997;
public static final int mtrl_bottom_sheet_slide_out = 2130771998;
public static final int mtrl_card_lowers_interpolator = 2130771999;
private anim() {
}
//未完只贴出了 anim资源。
}

可以看的出当我们代码里面使用R 的时候能够直接引用到相关的静态变,静态变量都是int整数,并且不重复。编译R文件是在编译代码之前进行的,所以代码可以直接引用R文件。

最后

以上就是执着抽屉为你收集整理的Android R文件分析的全部内容,希望文章能够帮你解决Android R文件分析所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部