본문 바로가기

color

[Android] getColor deprecated getColor 함수가 deprecated가 되어 임의로 함수를 사용하시는 분이 있을 듯 한데요.그냥 아래 같이 사용하시면 되겠습니다. ContextCompat.getColor(getApplicationContext(), R.color.color_res); 참고하세요. 더보기
[Android] Make CustomView (TextView, OnMeasure) CustomView를 만들어 보고자 합니다.하고자 하는 것은 TextView Background 에 기본적으로 RoundRect 가 그려지도록 할 예정입니다. 여기서 필요한 기술이 두가지 입니다. 1. Background를 어떻게 그리지??2. CustomeView의 크기를 어떻게 조절하지??? 모든것을 설명해 드릴 수 없지만, 개발하는데 유용할 만한 내용은 될것이라 생각 됩니다. 먼저, Background에 이미지를 넣을때 아래와 같은 방법을 많이 씁니다. (전..그랬음.._) - FrameLayout으로 감싼 후, Background로 활용할 이미지를 ImageView에 먼저 그린 후 그 다음으로 위에 표현하고자 하는 View를 올린다. 단점 ) View의 크기가 고정 되어 있지 않으면 (예를 들어 .. 더보기
[Android] getDrawable, getColor deprecated Resource로 Drawable이나 Color를 얻어오면 어떤 함수를 써야 할지 고민이 됩니다.그냥 아래 소스를 API로 만들어 놓은 후 호출하면 간편 합니다. public int getColor(Context context, int id) { final int version = Build.VERSION.SDK_INT; if (version >= Build.VERSION_CODES.M) { return context.getColor(id); } else { return context.getResources().getColor(id); } } public Drawable getDrawable(Context context, int id) { final int version = Build.VERSION.SD.. 더보기
[Android] NavigationView 커스텀화 NavigationView를 커스텀화 하기에 좋은 설명이 있어서 공유하고자 글을 씁니다. itemBackground, itemIconTint and itemTextColor are simple xml-attributes that can be set, though you have to use a custom prefix instead of the android: one.Example So if you wan't to customize the color of the text (e.g. pink when unchecked and teal when checked) you should use a ColorStateList.ExampleCreate a new *.xml file in /res/color - let'.. 더보기
[Android] 강제적으로 Toolbar arrow 변경 Toolbar arrow가 AppbarLayout에 포함 되지 않거나 단독으로 쓰고자 할 경우,검은색으로 고정되어 버리는 경우가 있다. 이럴 경우, 강제적으로 arrow를 바꿔줄 수 있는데 아래 소스 같이 하면 된다.if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha, null)); else getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.abc_ic_ab_bac.. 더보기
[ Android ] Preference 글자 색깔 이 내용은 글자 색깔 변경이 아니라는 것을 알려드립니다.다른게 아니라 혹시 자신이 Application에 Theme도 제대로 적용 시켰는데도 불구하고,글자가 회색으로 나오거나 전혀 다른 형태의 Preference로 보여지게 될 경우!!Preference 생성 시, 매개변수 넘긴 부분을 확인 해보세요. final Preference pref = new Preference(getApplicationContext());전 위 형태로 많이 사용하는데요. 매개변수로 getApplicationContext를 넣게 되면,현재 Activity의 환경으로 UI가 Setting이 되지 않아 보입니다. final Preference pref = new Preference(this);위와 같이 Activity를 그대로 thi.. 더보기
[ Android ] Color 값을 RGB로 public void toRGB(int color) { float red = color >> 16 & 0xff; float green = color >> 8 & 0xff; float blue = color & 0xff; Log.d("DEBUG1",red+" / "+green+ " / " +blue); } 간단한 함수이다.. 그래도 색깔 값을 이용할려면 자주 쓰일 듯하다. ㅎㅎ 더보기
[Android Opengl es 2.0 ] 여러 Object를 한 번에 그리기. 코딩을 하는 도중... 만약에 1000개 이상의 Object들을 한꺼번에 그릴 려고 할 때, For문으로 1000개를 돌려야 할까요???? 개발 요구사항에 따라 다르겠지만, 만약 전체적인 회전이나 컬러 알파 정도는 수정할 수 있는 방법이 있었습니다. 바로!!! 1000개의 Object의 Vertex를 지정하고, 한번에 그리는 것입니다.!!! ( 제가 초보라서.. 이제 알게됨..^^;) Vertex와 Index 배열을 잘 이용하면 쉽게 그릴 수 있습니다. 먼저 테스트 해본 배열은 private final float[] mVerticesData = { // X, Y, Z, U, V,alpha,colorR,colorG,colorB,colorA 0.0f, 0.5f, 0, 1.0f, 0.0f,1.0f,0.0f,0.. 더보기