1.

  1.  
  2. import android.content.Context;
  3. import android.content.res.TypedArray;
  4. import android.support.annotation.Nullable;
  5. import android.util.AttributeSet;
  6. import android.widget.ImageView;
  7.  
  8. import java.util.ArrayList;
  9.  
  10. public class RippleImageView extends ImageView {
  11. public static ArrayList<RippleImageView> ImageList = new ArrayList<RippleImageView>();
  12.  
  13. private boolean globalColor = false;
  14.  
  15. public RippleImageView(Context context, @Nullable AttributeSet attrs) {
  16. super(context, attrs);
  17. StatusBarUtils.RippleView(this, context);
  18.  
  19. TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.mk);
  20. globalColor = ta.getBoolean(R.styleable.mk_globalcolor, false);
  21. if(globalColor == true)
  22. {
  23. setColorFilter(ColorUtils.GlobalColor);
  24. }
  25.  
  26. if(ImageList.contains(this) == false)
  27. {
  28. ImageList.add(this);
  29. }
  30. }
  31.  
  32. public void ChangeColor(int Color)
  33. {
  34. if(globalColor == true)
  35. {
  36. setColorFilter(Color);
  37. }
  38. }
  39. }

2.

  1. import android.content.res.ColorStateList;
  2.  
  3. public class ColorUtils {
  4. public static int GlobalColor = 0xffd43b33;
  5. public static int GlobalColorSelected = 0xffffffff;
  6. public static String GlobalColorString = "#FFD43B33";
  7.  
  8. public static int GlobalTextColorTitle = 0xff606060;
  9. public static int GlobalTextColorSubtitle = 0xff7f7d7d;
  10.  
  11. public static ColorStateList colorStateList= null;
  12.  
  13. public static ColorStateList getColorStateList(int mode)
  14. {
  15. if(colorStateList == null)
  16. {
  17. int[][] states = new int[][];
  18. states[] = new int[]{android.R.attr.state_pressed};
  19. states[] = new int[]{android.R.attr.state_enabled};
  20.  
  21. int[] colors = new int[]{GlobalColor, GlobalColor};
  22.  
  23. colorStateList = new ColorStateList(states, colors);
  24. }
  25. return colorStateList;
  26. }
  27.  
  28. public static void SetThemeColor(int BackColor, boolean backColorLight)
  29. {
  30. GlobalColor = BackColor;
  31. if(backColorLight == true)
  32. {
  33. GlobalTextColorTitle = 0xff606060;
  34. GlobalTextColorSubtitle = 0xff7f7d7d;
  35. }
  36. else
  37. {
  38. GlobalTextColorTitle = 0xffffffff;
  39. GlobalTextColorSubtitle = 0xffd0cece;
  40. }
  41. }
  42.  
  43. }

3.

  1. import android.app.Activity;
  2. import android.app.Dialog;
  3. import android.content.Context;
  4. import android.content.res.TypedArray;
  5. import android.graphics.Color;
  6. import android.os.Build;
  7. import android.view.View;
  8. import android.view.Window;
  9. import android.view.WindowManager;
  10.  
  11. public class StatusBarUtils {
  12. public static void setWindowStatusBarColor(Activity activity, String color) {
  13. try {
  14. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  15. Window window = activity.getWindow();
  16. window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  17. window.setStatusBarColor(Color.parseColor(color));
  18.  
  19. //底部导航栏
  20. //window.setNavigationBarColor(activity.getResources().getColor(colorResId));
  21. }
  22. } catch (Exception e) {
  23. e.printStackTrace();
  24. }
  25. }
  26.  
  27. public static void setWindowStatusBarColor(Dialog dialog, String color) {
  28. try {
  29. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  30. Window window = dialog.getWindow();
  31. window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  32. window.setStatusBarColor(Color.parseColor(color));
  33.  
  34. //底部导航栏
  35. //window.setNavigationBarColor(activity.getResources().getColor(colorResId));
  36. }
  37. } catch (Exception e) {
  38. e.printStackTrace();
  39. }
  40. }
  41.  
  42. public static void RippleView(View view, Context context)
  43. {
  44. if(android.os.Build.VERSION.SDK_INT >= )
  45. {
  46. int[] attrsArray = { android.R.attr.selectableItemBackgroundBorderless };
  47. //TypedArray typedArray = activity.obtainStyledAttributes(attrsArray);
  48. TypedArray typedArray = context.obtainStyledAttributes(attrsArray);
  49. int selector = typedArray.getResourceId(, attrsArray[]);
  50. view.setBackgroundResource(selector);
  51. // don't forget the resource recycling
  52. typedArray.recycle();
  53. }
  54. else
  55. {
  56. int[] attrsArray = { android.R.attr.selectableItemBackground };
  57. TypedArray typedArray = context.obtainStyledAttributes(attrsArray);
  58. //TypedArray typedArray = getActivity().obtainStyledAttributes(attrsArray);
  59. int selector = typedArray.getResourceId(, attrsArray[]);
  60. view.setBackgroundResource(selector);
  61. typedArray.recycle();
  62. }
  63.  
  64. }
  65. }

3333_

  1. import android.content.Context;
  2. import android.content.Intent;
  3. import android.content.SharedPreferences;
  4. import android.graphics.Color;
  5. import android.graphics.PorterDuff;
  6. import android.support.design.widget.BottomSheetBehavior;
  7. import android.support.design.widget.CoordinatorLayout;
  8. import android.support.v4.app.FragmentManager;
  9. import android.support.v4.app.FragmentTransaction;
  10. import android.support.v4.widget.NestedScrollView;
  11. import android.support.v7.app.AppCompatActivity;
  12. import android.os.Bundle;
  13. import android.util.Log;
  14. import android.view.Gravity;
  15. import android.view.View;
  16. import android.widget.CompoundButton;
  17. import android.widget.ImageView;
  18. import android.widget.LinearLayout;
  19. import android.widget.RadioButton;
  20. import android.widget.Switch;
  21. import android.widget.TextView;
  22.  
  23. import org.greenrobot.eventbus.EventBus;
  24. import org.greenrobot.eventbus.Subscribe;
  25. import org.greenrobot.eventbus.ThreadMode;
  26.  
  27. import java.util.ArrayList;
  28. import java.util.List;
  29. import java.util.Observable;
  30.  
  31. public class MainActivity extends AppCompatActivity {
  32. private static final String TAG = "MainActivity";
  33. List<RippleImageView> viewlist=new ArrayList<>();
  34. //TextView textTest;
  35. ArrayList<ImageView> buttonGroup = new ArrayList<ImageView>();
  36. int selectedButtonID = -;
  37. BottomSheetBehavior behavior;
  38. String packName;
  39. int StyleNow; //1-Light Style 2-DarkStyle
  40. TextView textViewSongName ;
  41. TextView textViewSingerName;
  42.  
  43. /**
  44. * 自定义stylecolor 标识 1-6种
  45. */
  46. int styleNowColor;
  47. /**
  48. *
  49. * 添加部分 gxw 17/06/13
  50. */
  51. RippleImageView imageViewCD,imageViewSkip,imageViewNext,imageViewStop,imageViewMore;
  52.  
  53. /**
  54. * 需要改变颜色的底部五个image集合
  55. */
  56. RippleList rippleList;
  57. /**
  58. * 当前显示的fragment序号
  59. */
  60. int fragmentNow;
  61. /**
  62. * LinearLayout 界面顶部红色的部分(可以改变颜色的部分)
  63. */
  64. LinearLayout appBarLayoutUp;
  65. FragmentTransaction fragmentTransaction;
  66. FragmentManager fragmentManager;
  67.  
  68. /**
  69. * 判断HomeActivity需要进入哪个fragment
  70. */
  71. int type;
  72.  
  73. private void SetChecked(int id)
  74. {
  75. selectedButtonID = id;
  76. for(int i = ; i < buttonGroup.size(); i++)
  77. {
  78. if(id == i)
  79. {
  80. changeFragment(i+);
  81. Log.d(TAG, "SetChecked:选择 "+i);
  82. buttonGroup.get(i).setAlpha(1.0f);
  83. }
  84. else
  85. {
  86. buttonGroup.get(i).setAlpha(0.7f);
  87. }
  88. }
  89. }
  90.  
  91. @Override
  92. protected void onCreate(Bundle savedInstanceState) {
  93. super.onCreate(savedInstanceState);
  94. setContentView(R.layout.activity_main);
  95. EventBus.getDefault().register(this);
  96. type=getIntent().getIntExtra("type",);
  97. Log.d(TAG, "onCreate: +type=="+type);
  98. initView();
  99. initialize(type);
  100. packName = getPackageName();
  101. SharedPreferences prefs = getSharedPreferences(packName, Context.MODE_PRIVATE);
  102. StyleNow = prefs.getInt("Style", );
  103. if(StyleNow == ) {
  104. ColorUtils.SetThemeColor(0xffd43b33, true);
  105. }
  106. else if(StyleNow == )
  107. {
  108. ColorUtils.SetThemeColor(0xffd43b33, false);
  109. }
  110. textViewSongName = (TextView) findViewById(R.id.textViewSongName);
  111. textViewSingerName = (TextView) findViewById(R.id.textViewSingerName);
  112. TextView textViewScan = (TextView) findViewById(R.id.textViewScan);
  113. imageViewCD= (RippleImageView) findViewById(R.id.imageViewCD);
  114. StatusBarUtils.RippleView(textViewSongName, this);
  115. StatusBarUtils.RippleView(textViewSingerName, this);
  116. StatusBarUtils.RippleView(textViewScan, this);
  117. LinearLayout appBarLayoutUp = (LinearLayout)findViewById(R.id.appBarLayoutUp);
  118. appBarLayoutUp.setBackgroundColor(ColorUtils.GlobalColor);
  119.  
  120. ImageView imageViewProg = (ImageView)findViewById(R.id.imageViewProg);
  121. imageViewProg.setOnClickListener(new View.OnClickListener() {
  122. @Override
  123. public void onClick(View v) {
  124. SetChecked();
  125. }
  126. });
  127. ImageView imageViewSinger = (ImageView)findViewById(R.id.imageViewSinger);
  128. imageViewSinger.setOnClickListener(new View.OnClickListener() {
  129. @Override
  130. public void onClick(View v) {
  131. SetChecked();
  132. }
  133. });
  134. ImageView imageViewSong = (ImageView)findViewById(R.id.imageViewSong);
  135. imageViewSong.setOnClickListener(new View.OnClickListener() {
  136. @Override
  137. public void onClick(View v) {
  138. SetChecked();
  139. }
  140. });
  141. ImageView imageViewFavo = (ImageView)findViewById(R.id.imageViewFavo);
  142. imageViewFavo.setOnClickListener(new View.OnClickListener() {
  143. @Override
  144. public void onClick(View v) {
  145. SetChecked();
  146. }
  147. });
  148. ImageView imageViewRecord = (ImageView)findViewById(R.id.imageViewRecord);
  149. imageViewRecord.setOnClickListener(new View.OnClickListener() {
  150. @Override
  151. public void onClick(View v) {
  152. SetChecked();
  153. }
  154. });
  155. buttonGroup.add(imageViewProg);
  156. buttonGroup.add(imageViewSinger);
  157. buttonGroup.add(imageViewSong);
  158. buttonGroup.add(imageViewFavo);
  159. buttonGroup.add(imageViewRecord);
  160.  
  161. ImageView imageViewBagde = (ImageView)findViewById(R.id.imageViewBagde);
  162. final RippleImageView imageViewStop= (RippleImageView) findViewById(R.id.imageViewStop);
  163. imageViewStop.setOnClickListener(new View.OnClickListener() {
  164. @Override
  165. public void onClick(View v) {
  166. imageViewStop.ChangeColor(getResources().getColor(R.color.styleColor2));
  167. }
  168. });
  169.  
  170. BadgeView badge = new BadgeView(this);
  171. badge.setTargetView(imageViewBagde);
  172. badge.setBadgeGravity(Gravity.CENTER);
  173. badge.setBadgeCount();
  174. StatusBarUtils.setWindowStatusBarColor(this, ColorUtils.GlobalColorString);
  175. ImageView imageViewMore = (ImageView)findViewById(R.id.imageViewMore);
  176. imageViewMore.setOnClickListener(new View.OnClickListener() {
  177. @Override
  178. public void onClick(View v) {
  179. if(behavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
  180. /**
  181. * 加的
  182. */
  183. MainActivity.this.finish();
  184. behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
  185. }else {
  186. behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
  187. }
  188. }
  189. });
  190. NestedScrollView nsView = (NestedScrollView)findViewById(R.id.bottomSetting);
  191. behavior = BottomSheetBehavior.from(nsView);
  192. behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
  193. ImageView imageViewBackFromSetting = (ImageView)findViewById(R.id.imageViewBackFromSetting);
  194. RadioButton rb1 = (RadioButton)findViewById(R.id.radioButtonLight);
  195. rb1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  196. @Override
  197. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  198. if(isChecked == true)
  199. {
  200. StyleNow = ;
  201. EventBus.getDefault().post(new Message());
  202. CoordinatorLayout coordinatorLayout= (CoordinatorLayout) findViewById(R.id.layoutbase);
  203. coordinatorLayout.setBackgroundResource(R.drawable.bg01);
  204. }
  205. }
  206. });
  207. RadioButton rb2 = (RadioButton)findViewById(R.id.radioButtonDark);
  208. rb2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  209. @Override
  210. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  211. if(isChecked == true)
  212. {
  213. StyleNow = ;
  214. EventBus.getDefault().post(new Message());
  215. CoordinatorLayout coordinatorLayout= (CoordinatorLayout) findViewById(R.id.layoutbase);
  216. coordinatorLayout.setBackgroundResource(R.drawable.bg02);
  217. }
  218. }
  219. });
  220. if(StyleNow == )
  221. {
  222. rb1.setChecked(true);
  223. textViewSongName.setTextColor(getResources().getColor(R.color.lightStyle_TextColor));
  224. textViewSingerName.setTextColor(getResources().getColor(R.color.lightStyle_TextColor));
  225. }
  226. else if(StyleNow == )
  227. {
  228. rb2.setChecked(true);
  229. textViewSongName.setTextColor(getResources().getColor(R.color.darkStyle_TextColor));
  230. textViewSingerName.setTextColor(getResources().getColor(R.color.darkStyle_TextColor));
  231. }
  232.  
  233. imageViewBackFromSetting.setOnClickListener(new View.OnClickListener() {
  234. @Override
  235. public void onClick(View v) {
  236. if(StyleNow == ) {
  237. ColorUtils.SetThemeColor(0xffd43b33, true);
  238.  
  239. }
  240. else if(StyleNow == )
  241. {
  242. ColorUtils.SetThemeColor(0xffd43b33, false);
  243. }
  244. SharedPreferences prefs = getSharedPreferences(packName, Context.MODE_PRIVATE);
  245. SharedPreferences.Editor ed = prefs.edit();
  246. ed.putInt("Style", StyleNow);
  247. ed.commit();
  248. behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
  249. }
  250. });
  251.  
  252. SetChecked(type-);
  253. imageViewCD.setOnClickListener(new View.OnClickListener() {
  254. @Override
  255. public void onClick(View v) {
  256. startActivity(new Intent(MainActivity.this, PlayActivity.class));
  257. }
  258. });
  259.  
  260. }
  261.  
  262. /**
  263. * gxw 17/06/13
  264. */
  265.  
  266. public void initialize( int type){
  267. fragmentManager=getSupportFragmentManager();
  268. fragmentTransaction=fragmentManager.beginTransaction();
  269. fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
  270. switch (type){
  271. case :
  272. fragmentTransaction.replace(R.id.fragmentlayout,new ProFragment());
  273. fragmentNow=;
  274. break;
  275. case :
  276. fragmentTransaction.replace(R.id.fragmentlayout,new SingerFragment());
  277. fragmentNow=;
  278. break;
  279. case :
  280. fragmentTransaction.replace(R.id.fragmentlayout,new SongFragment());
  281. fragmentNow=;
  282. break;
  283. case :
  284. fragmentTransaction.replace(R.id.fragmentlayout,new FavoFragment());
  285. fragmentNow=;
  286. break;
  287. case :
  288. fragmentTransaction.replace(R.id.fragmentlayout,new RecordFragment());
  289. fragmentNow=;
  290. break;
  291. }
  292.  
  293. fragmentTransaction.commit();
  294.  
  295. }
  296.  
  297. public void changeFragment(int i){
  298. fragmentManager=getSupportFragmentManager();
  299. fragmentTransaction=fragmentManager.beginTransaction();
  300. /**
  301. * 判断动画的切换方向
  302. */
  303. if(fragmentNow>i){
  304. fragmentTransaction.setCustomAnimations(R.anim.push_left_in,R.anim.push_left_out);
  305. }else if(fragmentNow<i){
  306. fragmentTransaction.setCustomAnimations(R.anim.back_left_in,R.anim.back_right_out);
  307. }
  308.  
  309. switch (i){
  310. case :
  311. fragmentTransaction.replace(R.id.fragmentlayout,new ProFragment());
  312. fragmentNow=;
  313. break;
  314. case :
  315. fragmentTransaction.replace(R.id.fragmentlayout,new SingerFragment());
  316. fragmentNow=;
  317. break;
  318. case :
  319. fragmentTransaction.replace(R.id.fragmentlayout,new SongFragment());
  320. fragmentNow=;
  321. break;
  322. case :
  323. fragmentTransaction.replace(R.id.fragmentlayout,new FavoFragment());
  324. fragmentNow=;
  325. break;
  326. case :
  327. fragmentTransaction.replace(R.id.fragmentlayout,new RecordFragment());
  328. fragmentNow=;
  329. break;
  330.  
  331. }
  332.  
  333. // fragmentTransaction.addToBackStack(null);
  334. fragmentTransaction.commit();
  335.  
  336. }
  337.  
  338. @Subscribe(threadMode = ThreadMode.MAIN)
  339. public void onEventMainThread(com.multak.cookaraclient.info.Message msg){
  340. if(msg.getStyle() == )
  341. {
  342. textViewSongName.setTextColor(getResources().getColor(R.color.lightStyle_TextColor));
  343. textViewSingerName.setTextColor(getResources().getColor(R.color.lightStyle_TextColor));
  344. }
  345. else if(msg.getStyle() == )
  346. {
  347. textViewSongName.setTextColor(getResources().getColor(R.color.darkStyle_TextColor));
  348. textViewSingerName.setTextColor(getResources().getColor(R.color.darkStyle_TextColor));
  349. }
  350. }
  351.  
  352. public void initView(){
  353. appBarLayoutUp= (LinearLayout) findViewById(R.id.appBarLayoutUp);
  354. int x=SharedPreferencesUtils.getParam(this,"StyleNowColor",);
  355. Log.d(TAG, "initView: 颜色1::"+x);
  356. imageViewCD= (RippleImageView) findViewById(R.id.imageViewCD);
  357. imageViewSkip= (RippleImageView) findViewById(R.id.imageViewSkip);
  358. imageViewNext= (RippleImageView) findViewById(R.id.imageViewNext);
  359. imageViewStop= (RippleImageView) findViewById(R.id.imageViewStop);
  360. imageViewMore= (RippleImageView) findViewById(R.id.imageViewMore);
  361. viewlist.add(imageViewCD);
  362. viewlist.add(imageViewSkip);
  363. viewlist.add(imageViewNext);
  364. viewlist.add(imageViewStop);
  365. viewlist.add(imageViewMore);
  366. rippleList=new RippleList(viewlist,this);
  367. setStatubar(x);
  368. rippleList.setColor(x);
  369.  
  370. //rippleList.setLinearLayout(appBarLayoutUp,x);
  371. appBarLayoutUp.setBackgroundColor(getResources().getColor(R.color.styleColor4));
  372.  
  373. }
  374.  
  375. /**
  376. *
  377. * @param view 自定义颜色选择,并作操作处理
  378. */
  379. public void setStyleColor(View view){
  380. switch (view.getId()){
  381. case R.id.textView_styleColor1:
  382. rippleList.setColor();
  383. rippleList.setSharep();
  384. int x= (Integer) SharedPreferencesUtils.getParam(this,"StyleNowColor",);
  385. Log.d(TAG, "setStyleColor: 颜色12:"+x);
  386. appBarLayoutUp.setBackgroundColor(getResources().getColor(R.color.styleColor1));
  387. setStatubar();
  388. break;
  389. case R.id.textView_styleColor2:
  390. rippleList.setColor();
  391. rippleList.setSharep();
  392. setStatubar();
  393. break;
  394. case R.id.textView_styleColor3:
  395. rippleList.setColor();
  396. rippleList.setSharep();
  397. setStatubar();
  398. break;
  399. case R.id.textView_styleColor4:
  400. rippleList.setColor();
  401. rippleList.setSharep();
  402. setStatubar();
  403. break;
  404. case R.id.textView_styleColor5:
  405. rippleList.setColor();
  406. rippleList.setSharep();
  407. setStatubar();
  408. break;
  409. case R.id.textView_styleColor6:
  410. rippleList.setColor();
  411. rippleList.setSharep();
  412. setStatubar();
  413. break;
  414. default:
  415. break;
  416. }
  417.  
  418. }
  419.  
  420. public void setStatubar(int i) {
  421. switch (i) {
  422. /**
  423. * <color name="styleColor1">#1FC4C4</color>
  424. <color name="styleColor2">#71C41F</color>
  425. <color name="styleColor3">#5B0CAA</color>
  426. <color name="styleColor4">#BABA20</color>
  427. <color name="styleColor5">#AA0C5B</color>
  428. <color name="styleColor6">#D43B33</color>
  429. */
  430. case :
  431. StatusBarUtils.setWindowStatusBarColor(this, "1FC4C4");
  432.  
  433. break;
  434. case :
  435. StatusBarUtils.setWindowStatusBarColor(this, "#71C41F");
  436. break;
  437. case :
  438. StatusBarUtils.setWindowStatusBarColor(this, "#5B0CAA");
  439. break;
  440. case :
  441. StatusBarUtils.setWindowStatusBarColor(this, "#BABA20");
  442. break;
  443. case :
  444. StatusBarUtils.setWindowStatusBarColor(this, "#AA0C5B");
  445. break;
  446. case :
  447. StatusBarUtils.setWindowStatusBarColor(this, "#D43B33");
  448. break;
  449.  
  450. }
  451.  
  452. }
  453.  
  454. }
  1. import android.content.Context;
  2. import android.content.SharedPreferences;
  3. import android.widget.LinearLayout;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.List;
  7.  
  8. /**
  9. * Created by guoxw on 2017/6/20.
  10. */
  11.  
  12. public class RippleList {
  13.  
  14. List<RippleImageView>data=new ArrayList<>();
  15. Context context;
  16.  
  17. public RippleList(List<RippleImageView> data, Context context) {
  18. this.data = data;
  19. this.context = context;
  20. }
  21.  
  22. public void setColor(int i){
  23. if(i==)
  24. {
  25. for (RippleImageView ripp : data) {
  26. ripp.ChangeColor(context.getResources().getColor(R.color.styleColor1));
  27. }
  28. }
  29. if(i==)
  30. {
  31. for (RippleImageView ripp : data) {
  32. ripp.ChangeColor(context.getResources().getColor(R.color.styleColor2));
  33. }
  34. }
  35.  
  36. if(i==)
  37. {
  38. for (RippleImageView ripp : data) {
  39. ripp.ChangeColor(context.getResources().getColor(R.color.styleColor3));
  40. }
  41. }
  42. if(i==)
  43. {
  44. for (RippleImageView ripp : data) {
  45. ripp.ChangeColor(context.getResources().getColor(R.color.styleColor4));
  46. }
  47. }
  48. if(i==)
  49. {
  50. for (RippleImageView ripp : data) {
  51. ripp.ChangeColor(context.getResources().getColor(R.color.styleColor5));
  52. }
  53. }
  54. if(i==)
  55. {
  56. for (RippleImageView ripp : data) {
  57. ripp.ChangeColor(context.getResources().getColor(R.color.styleColor6));
  58. }
  59. }
  60. }
  61.  
  62. public void setSharep(int i){
  63. SharedPreferencesUtils.setParam(context,"StyleNowColor",i);
  64. }
  65.  
  66. public void setLinearLayout(LinearLayout lauout, int i){
  67. switch (i){
  68. case :
  69. lauout.setBackgroundColor(context.getResources().getColor(R.color.styleColor1));
  70. break;
  71. case :
  72. lauout.setBackgroundColor(context.getResources().getColor(R.color.styleColor2));
  73. break;
  74. case :
  75. lauout.setBackgroundColor(context.getResources().getColor(R.color.styleColor3));
  76. break;
  77. case :
  78. lauout.setBackgroundColor(context.getResources().getColor(R.color.styleColor4));
  79. break;
  80. case :
  81. lauout.setBackgroundColor(context.getResources().getColor(R.color.styleColor5));
  82. break;
  83. case :
  84. lauout.setBackgroundColor(context.getResources().getColor(R.color.styleColor6));
  85. break;
  86.  
  87. }
  88.  
  89. }
  90.  
  91. }
  1. import android.content.Context;
  2. import android.content.SharedPreferences;
  3.  
  4. /**
  5. * Created by guoxw on 2017/6/20.
  6. */
  7.  
  8. public class SharedPreferencesUtils {
  9. private static String NAME="com.multak.cookaraclient1";
  10. public static void setParam(Context context, String key, int x){
  11. SharedPreferences prefs = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
  12. SharedPreferences.Editor ed = prefs.edit();
  13. ed.putInt(key, x);
  14. ed.commit();
  15.  
  16. }
  17. public static int getParam(Context context,String key,int y){
  18. SharedPreferences p=context.getSharedPreferences(NAME,Context.MODE_PRIVATE);
  19. return p.getInt(key,y);
  20.  
  21. }
  22.  
  23. }

<改变imageView的颜色和状态栏>的更多相关文章

  1. 简单物联网:外网访问内网路由器下树莓派Flask服务器

    最近做一个小东西,大概过程就是想在教室,宿舍控制实验室的一些设备. 已经在树莓上搭了一个轻量的flask服务器,在实验室的路由器下,任何设备都是可以访问的:但是有一些限制条件,比如我想在宿舍控制我种花 ...

  2. 利用ssh反向代理以及autossh实现从外网连接内网服务器

    前言 最近遇到这样一个问题,我在实验室架设了一台服务器,给师弟或者小伙伴练习Linux用,然后平时在实验室这边直接连接是没有问题的,都是内网嘛.但是回到宿舍问题出来了,使用校园网的童鞋还是能连接上,使 ...

  3. 外网访问内网Docker容器

    外网访问内网Docker容器 本地安装了Docker容器,只能在局域网内访问,怎样从外网也能访问本地Docker容器? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Docker容器 ...

  4. 外网访问内网SpringBoot

    外网访问内网SpringBoot 本地安装了SpringBoot,只能在局域网内访问,怎样从外网也能访问本地SpringBoot? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装Java 1 ...

  5. 外网访问内网Elasticsearch WEB

    外网访问内网Elasticsearch WEB 本地安装了Elasticsearch,只能在局域网内访问其WEB,怎样从外网也能访问本地Elasticsearch? 本文将介绍具体的实现步骤. 1. ...

  6. 怎样从外网访问内网Rails

    外网访问内网Rails 本地安装了Rails,只能在局域网内访问,怎样从外网也能访问本地Rails? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Rails 默认安装的Rails端口 ...

  7. 怎样从外网访问内网Memcached数据库

    外网访问内网Memcached数据库 本地安装了Memcached数据库,只能在局域网内访问,怎样从外网也能访问本地Memcached数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装 ...

  8. 怎样从外网访问内网CouchDB数据库

    外网访问内网CouchDB数据库 本地安装了CouchDB数据库,只能在局域网内访问,怎样从外网也能访问本地CouchDB数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动Cou ...

  9. 怎样从外网访问内网DB2数据库

    外网访问内网DB2数据库 本地安装了DB2数据库,只能在局域网内访问,怎样从外网也能访问本地DB2数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动DB2数据库 默认安装的DB2 ...

  10. 怎样从外网访问内网OpenLDAP数据库

    外网访问内网OpenLDAP数据库 本地安装了OpenLDAP数据库,只能在局域网内访问,怎样从外网也能访问本地OpenLDAP数据库? 本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动 ...

随机推荐

  1. redis的跳跃表

    跳跃表是一种插入.查询.删除的平均时间复杂度为O(nlogn)的数据结构,在最差情况下是O(n),当然这几乎很难出现. 和红黑树相比较 最差时间复杂度要差很多,红黑树是O(nlogn),而跳跃表是O( ...

  2. VGG 19

    关于VGG19的一些参考资料 http://www.cnblogs.com/vipyoumay/archive/2017/11/23/7884472.html https://cloud.tencen ...

  3. ionic3、Angular4 定时器的使用

    // 声明变量 applicationInterval:any; // 定时器 // 使用定时器,每秒执行一次 ionViewDidEnter(){ let that = this; let appl ...

  4. java操作Excel的poi基础语法

    创建一个简单的实列 package com.java.poi; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache ...

  5. SaltStact自动化运维工具02

     Grains基础:• Grains是saltstack最重要的组件之一• 存储minion端的基本信息,这些信息一般都是静态的,如CPU.内核.操作系统等• Grains存储在minion本地• 管 ...

  6. Linux分布式测试

    在使用Jmeter进行性能测试时,如果并发数比较大(比如最近项目需要支持1000并发),单台电脑的配置(CPU和内存)可能无法支持,这时可以使用Jmeter提供的分布式测试的功能. 执行机和调度机做好 ...

  7. jemeter参数化读取文件

    1.新建一个123.csv文件 如图 2.添加http请求 3.添加一个查看结果树 二.通过函数助手 (1)打开函数助手 ......... 在json属组中引入变量  这是别人参考的

  8. 我的第一个arcgis地图应用

    步骤: 1.设置一个基本的html文档 <!DOCTYPE html> <html> <head> <meta http-equiv="Conten ...

  9. 关于excel导出

    转载自:https://blog.csdn.net/ljj_9/article/details/50395688 //一个excel表格: HSSFWorkbook wb = new HSSFWork ...

  10. js面向对象编程: js类定义函数时prototype和this差别?

    在面向对象编写js脚本时,定义实例方法主要有两种 例如以下: function ListCommon2(afirst) { var first=afirst; this.do1=function () ...