'Android'에 해당되는 글 4건
- 2016.10.15 Execution failed for task 'app:mergeDebugResources' Crunching Cruncher
- 2016.09.22 layout에 view 동적으로 생성하기 (Add imageView and textView to linearLayout programmatically)
- 2016.09.16 Unable to build apk: The number of method references cannot exceed 64K
- 2016.01.17 안드로이드 스튜디오에서 로컬라이징 설정 (Android Localization)
layout에 view 동적으로 생성하기 (Add imageView and textView to linearLayout programmatically)
Android 2016. 9. 22. 09:561. textView 동적 생성
// textView가 추가될 linearLayout
LinearLayout layout = (LinearLayout) layout.findViewById(R.id.linearLayout);
// layout param 생성
LayoutParams layoutParams =
new LayoutParams(LayoutParams.MATCH_PARENT /* layout_width */, LayoutParams.WRAP_CONTENT /* layout_height */, 1f /* layout_weight */);
TextView tv = new TextView(this); // 새로 추가할 textView 생성
tv.setText("new TextView"); // textView에 내용 추가
tv.setLayoutParams(textParams); // textView layout 설정
tv.setGravity(Gravity.CENTER); // textView layout 설정
layout.addView(tv); // 기존 linearLayout에 textView 추가
2. imageView 동적 생성
// imageView가 추가될 linearLayout
LinearLayout layout = (LinearLayout) layout.findViewById(R.id.linearLayout);
// layout param 생성
LayoutParams layoutParams =
new LayoutParams(LayoutParams.MATCH_PARENT /* layout_width */, LayoutParams.WRAP_CONTENT /* layout_height */, 1f /* layout_weight */);
ImageView iv = new ImageView(this); // 새로 추가할 imageView 생성
iv.setImageResource(R.drawable.image); // imageView에 내용 추가
iv.setLayoutParams(textParams); // imageView layout 설정
layout.addView(iv); // 기존 linearLayout에 imageView 추가
'Android' 카테고리의 다른 글
댓글을 달아 주세요
build.gradle 파일 내 defaultConfig 에 multiDexEnabled true 를 입력하면 해결
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.gkwak.***" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" multiDexEnabled true // 이곳에 추가 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } | cs |
참고 : https://developer.android.com/studio/build/multidex.html
'Android' 카테고리의 다른 글
댓글을 달아 주세요
Android Localization
strings.xml에 입력된 스트링을 해당 기기의 Locale 에 따라 해당하는 언어로 보여준다.
안드로이드 스튜디오에서는 Translation Editor라는 것을 통해 손쉽게 로컬라이징 작업을 도와준다.
1. 안드로이드 스튜디오 프로젝트탭에서 res/values/strings.xml 마우스 우클릭 후 Translationg Editor를 클릭한다.
2. Translationg Editor에 들어간 뒤 빨간 동그라미를 클릭하면 설정할 국가가 나오고 거기에 해당 국가를 찾아서 클릭 하면 빨간 네모 영역에 선택한 국가가 생기게 된다.
3 . 이제 녹색 + 버튼을 누른 뒤 사용할 스트링코드와 default value를 입력한다. ( default value의 Locale은 미국이다. )
4. 해당 국가 탭에 해당 국가에 맞는 언어로 번역하여 스트링을 넣으면 된다.
5. 필요한 모든 번역을 완료하고 테스트하기 위해선 AVD나 실제 기기를 이용하여 테스트 앱을 구동한 뒤 설정에서 언어를 번역하고 싶은 언어로 변경하면 스트링이 제대로 번역되었는지 확인할 수 있다.
댓글을 달아 주세요