본문 바로가기

분류 전체보기

android Lollipop black image / 롤리팝에서 라운딩 이미지가 검정색으로 나올때 갤러리에서 선택한 이미지를 라운딩하여 프로필 사진으로 등록하는 기능을 구현중이다. 구글링해보니 별개의 Drawable 클래스를 만드는 등 복잡한 방법들이 난무하다. 분명 안드로이드라면 간단히 해결할 수 있는 객체가 지원될텐데.. 이상하다고 생각하여 안드로이드 개발자 웹에서 검색해보니 아래와 같이 좋은것이 있다.RoundedBitmapDrawable 깔끔하게 단 몇줄의 코드만으로 라운딩 이미지를 출력할 수 있다. 12345 private void setRoundedProfileImage(Bitmap bitmap) { RoundedBitmapDrawable result = RoundedBitmapDrawableFactory.create(getResources(), bitmap); result.setCircu.. 더보기
[selector] 버튼/텍스트뷰의 background와 textColor selector 설정 커스텀한 디자인의 버튼을 만들려고 한다. press 상태일 때 테두리, 배경, 텍스트 컬러가 모두 변경되어야 한다. 1. [X] TextView의 textColor와 backround 속성에 selector 넣기 12345Colored by Color Scriptercs 2. [X] TextView의 background 속성에 넣을 selector에 테두리, 배경, 텍스트 컬러 설정하기 12345678910111213141516171819202122232425262728293031 Colored by Color Scriptercs 3. [O] TextView를 RelativeLayout으로 감싼다. RelativeLayout에 clickable 속성을 준다.RelativeLayout의 background.. 더보기
fragment에서 onActivityResult() 받기 MainFragment에서 onActivityResult()가 호출되어야 하는데, MainActivity에서 onActivityResult()가 호출된다. - Dialog에서 fragment.startActivityForResult()를 호출할 수 없다. MainActivity의 lifecycle에 따라 동작하도록 되어있다. - 이벤트 버스를 만드려면 복잡하다. - Activity의 onActivityResult()에서 requestCode를 변환하고 Fragment의 onActivityResult()를 직접 호출하도록 했다. 정상 동작한다. 123456789//Activity의 onActivityResult() @Overrideprotected void onActivityResult(int reques.. 더보기
액티비티(프래그먼트) 간에 객체나 리스너를 공유하면 안된다. 서로 다른 패키지의 액티비티와 프래그먼트 간에 처리해야할 이벤트가 있어서 리스너와 static method로 구현했다. 하지만 액티비티 끼리는 인텐트를 이용해야한다. 안드로이드에서 인텐트를 적극 활용할 줄 알아야한다. 앱 컴포넌트(서비스, 브로드캐스트리시버, 컨텐트프로바이더, 액티비티)는 인텐트를 사용하자! 더보기
ScrollView의 height를 match_parent하기 ScrollView 의 속성인 fillViewPort에 true 값을 주면 화면의 세로 영역에 꽉 찬다. 더보기
배열 객체는 가급적 쓰지말자 List에 여러 문자열을 추가할 때, 배열 객체를 사용하면 안좋다. 다루기 어렵다.(정확한 이유는 아직 모름. 이펙티브 자바에도 내용 없음) 123456789 String[] categories = { getString(R.string.category_korea), getString(R.string.category_china), getString(R.string.category_japan) }; List list = new ArrayList(); list.addAll(Arrays.asList(categories)); Colored by Color Scriptercs List 객체로 만들어서 복사하거나 array xml을 이용하자. 12345678 @string/category_korea @string/c.. 더보기
White04 현재진행 4 :: 현재진행이지만 미래이야기 1. 현재진행이 미래가 될 수 있다.미래 계획을 나타낼때만 미래의 의미를 쓸 수 있다.will은 잘 안쓰고 be going to를 많이 사용한다.What are you going to do tonight? 2. go 동사가 ing랑 궁합 좋은것 go skiinggo skatinggo hikinggo snorkelinggo scuba divinggo swimminggo window shopping (eye shopping은 콩글리쉬) 3. sth의 시작/중간/끝the start of sth (전치사는 at)the start of next month 다음달 초the start of this month 이번달 초the start of last month 지난달 초at the start of this year .. 더보기
[Android] input String quotes in BuildConfig I clone some project. To run app, must input my API KEY instead of placeholder. In above file, I input my API KEY instead of "MyOpenWeatherMapApiKey".But BuildConfig.java linked with app/build.gradle doesn't create quotes(") and occurs error. app/build.gradle 12345678910111213141516171819202122232425262728apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "2.. 더보기