본문 바로가기

change

[Android] android.net.conn.CONNECTIVITY_CHANGE 안드로이드에서 네트워크가 끊겼는지 실시간으로 알아보는 방법으로 아래와 같이 사용하시는 분들도 있을 것이다. // Broadcast Listener 등록 (onCreate나 onResume에 할당)IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); try{ registerReceiver(mNetworkStateReceiver, filter); }catch (Exception e){ if (RingQConfig.DEBUG) e.printStackTrace(); } // Broadcast Listener 해제 (onDestroy나 onPause에 할당)try { if (mNetworkStateReceiver != nu.. 더보기
[Android] Make CustomView (TextView, OnMeasure) CustomView를 만들어 보고자 합니다.하고자 하는 것은 TextView Background 에 기본적으로 RoundRect 가 그려지도록 할 예정입니다. 여기서 필요한 기술이 두가지 입니다. 1. Background를 어떻게 그리지??2. CustomeView의 크기를 어떻게 조절하지??? 모든것을 설명해 드릴 수 없지만, 개발하는데 유용할 만한 내용은 될것이라 생각 됩니다. 먼저, Background에 이미지를 넣을때 아래와 같은 방법을 많이 씁니다. (전..그랬음.._) - FrameLayout으로 감싼 후, Background로 활용할 이미지를 ImageView에 먼저 그린 후 그 다음으로 위에 표현하고자 하는 View를 올린다. 단점 ) View의 크기가 고정 되어 있지 않으면 (예를 들어 .. 더보기
[Android] Background animation에 쓸만한 TransitionDrawable 혹시 RadioButton 이나 Switch 관련된 View를 사용하고자 할 경우, 한번 고려해보면 나쁘지 않을 것이다.그냥 xml로 정의 해서 background에 넣는 방법이 있고, 직접 코드에 넣을 수도 있다. 1. xml로 정의 res/drawable 폴더안에 btn_transition_drawable.xml 라는 xml 파일을 만들어 놓고, 아래 소스대로 코딩 합니다. 그 다음, 사용하고자 하는 View background에 위 xml로 설정 합니다.이로써 설정은 끝났습니다.이제 TransitionDrawable에 Animation을 동작하게 하는 코드만 넣어주면 됩니다.코드는 아래와 같습니다.// set background animation Drawable drawable = findViewB.. 더보기
[Android] Font Library 디폴트 폰트를 바꾸기에 좋은 Library가 있어 공유하고자 합니다. https://github.com/tsengvn/typekit 1. main/assets 폴더 를 만든 후, 해당 폴더에 ttf나 otf 같은 폰트 파일을 복사 합니다. Typekit is a library that help you quick change default font of your android application. You don't need to add any custom view or tag to your current xml layout file. You make a quick config in your application class and change the font that you need specific for.. 더보기
[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.. 더보기
[Andoird] Button 클릭 시, textColor 변경 text_selector.xml layout.xml 위와 같이 하면 적용 된다. Java 단에서 하고자 한다면 아래 소스를 참고 하세요. 예) /res/color/selector_text.xml123456 ;버튼이 xml layout 에 있는 경우는 그냥 android:textColor=”@color/selector_text.html” 로 지정해주면 되지만,만약 java 안에서 프로그램적으로 세팅해 주는 경우는 다음과 같은 코드를 써야 한다.123btnTest.setTextColor( getResources().getColorStateList(R.color.selector_text));이렇게 안 하고 그냥 getColor() 를 사용하면 버튼 터치 시 색 변화가 없다.출처 : https://chrisjh.. 더보기
[Android] Recycler View 사이에 divider 크기 조절 RecyclerView는 각 Row에 Decoration을 줄 수가 있습니다. 이때 사용하는 클래스가 RecyclerView.ItemDecoration 입니다. 간단하게 리스트 사이에 간격을 별려주는 소스 입니다. public class CustomRecyclerDecoration extends RecyclerView.ItemDecoration { private final int divHeight; public CustomRecyclerDecoration(int divHeight) { this.divHeight = divHeight; } @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerVie.. 더보기