Android 反射实战 - 更换APP皮肤<2>
来源:互联网 发布:spss22 mac版教程 编辑:程序博客网 时间:2024/06/15 20:49
前面通过实现Factory来获取所有的UI和属性等.将前面那个工程进行调整,参考其他网络上面的一些信息,调整和更新ActionBar右上角的menu字体颜色和背景,通过这个小例子,从某种程度可以反映更换APP皮肤基本的思路.
package com.oneplus.factoryimplapp;import android.app.Activity;import android.content.Context;import android.os.Bundle;import android.os.Handler;import android.util.AttributeSet;import android.view.InflateException;import android.view.LayoutInflater;import android.view.Menu;import android.view.View;import android.widget.TextView;import com.oneplus.factoryimplapp.R;import com.oneplus.base.OneplusBaseActivity;/** * *//** * @author zhibao.liu * @date 2015-12-8 * @company : oneplus.Inc */public class OneplusFactoryActivity extends /*OneplusBase*/Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.oneplus_factory); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.oneplus_factory, menu); setMenuBackground(); return true; } /** set menu style */ protected void setMenuBackground() { this.getLayoutInflater().setFactory( new android.view.LayoutInflater.Factory() { public View onCreateView(String name, Context context,AttributeSet attrs) { // set self-define inflate if (name.equalsIgnoreCase("TextView")) { try { LayoutInflater f = getLayoutInflater(); final View view = f.createView(name, null,attrs); new Handler().post(new Runnable() { public void run() { // set background color view.setBackgroundResource(R.color.oneplus_menu); // set font color ((TextView) view).setTextColor(0xff0000ff); } }); return view; } catch (InflateException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } return null; } } ); }}
这是一个非常简单的更新style的例子.
0 0
- Android 反射实战 - 更换APP皮肤<2>
- Android 反射实战 - 更换APP皮肤<1>
- Android 反射实战 - 更换APP皮肤<3>
- Android爱读app开发记录之三---皮肤更换
- android----------更换皮肤
- Android更换皮肤
- Android更换皮肤解决方案
- Android 皮肤的更换
- Android实现更换皮肤功能
- android 更换皮肤(主题)
- Android实现更换皮肤功能
- Android应用实现更换皮肤功能
- 轻松实现Android 更换皮肤(主题)
- 轻松实现Android 更换皮肤(主题)
- Android 更换皮肤思路及解决方案
- 轻松实现Android 更换皮肤(主题)
- 轻松实现Android更换皮肤(主题)
- 轻松实现Android 更换皮肤(主题)
- 树莓派python,tornado,返回json数据代码,初级网络编程。
- iOS框架介绍——M字头
- 最简单的matplotlib安装和使用
- jquery 的ajax 用法
- Data Structure(1-6)---单链表的整表创建
- Android 反射实战 - 更换APP皮肤<2>
- Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法
- UART0串口编程系列 串口编程(UART0)之中断方式(一)
- C# 反射 通过类名创建类实例
- 使用系统时间作为创建的文件名
- iOS 分享功能开发
- c++实现的快速排序算法
- 纯文本转超文本
- mac 安装python软件包的工具--easy_install