본문 바로가기

안드로이드/앱 개발

(9)
[Kotlin] 현재 화면의 크기를 가져오는 방법 연습용 앱이 아닌 출시용 앱은 천차만별인 안드로이드 단말들의 화면 크기를 커버할 수 있어야 한다. 특히 해외 출시의 경우, 플래그십 모델을 선호하는 한국과 달리 다양한 크기의 화면들을 사용하고 있어 더욱 중요한 것 같다. 기존에 알려져 있는 방법인 windowManager.defaultDisplay ~ 는 deprecated 되어서, 이 방법이 코틀린의 최신 버전인 것 같다. val height = resources.displayMetrics.heightPixels val width = resources.displayMetrics.widthPixels 여기저기 쓸 수 있어서 기본적으로 알아놓아야 한다. val height = resources.displayMetrics.heightPixels * 8.0 ..
NestedScrollView 스크롤 위치가 이상할 때 바텀 슬라이딩 안에 RecyclerView 가 여러 개 들어가는 NestedScrollView 를 만들었다. 그런데 특정 단말기에서 스크롤의 포커스가 이상하게 두번째 리사이클러뷰에 맞춰지는 것을 발견. Note 10+ 에선 발생하지 않았던 문제였는데, s7으로 테스트하니 발견할 수 있었다. 이건 간단하게 해결할 수 있다. 하위 뷰들이 포커스를 받지 못하도록 하는 속성을 넣어주면 된다. NestedScrollView 를 사용할 때 포커스 문제를 종종 발견하는데, 이 속성을 추가하면 해결이 바로 가능하다. // recyclerView 를 감싸고 있는 ConstraintLayout // recylerView 들 여러개 참고. https://developer.android.com/reference/android..
구글 지도의 모양을 변경하고 싶을 때 (outlineProvider) 개발 중, 클라이언트의 요청에 따라 구글 지도에 아랫 부분만 라운딩을 넣어야할 때가 있었다. 보통 뷰의 코너에 라운딩을 넣을 때는 shape.xml 파일을 만들어서 background에 적용하고, clipToOutline을 사용하는 방법을 쓴다. 라운딩 요청이 개발 말미에 들어왔기 때문에, 기존에 만들어놓은 맵뷰를 최대한 고치지 않고 사용하고 싶었다. 처음엔 당연히 레이아웃 파일의 background를 사용했다. 그런데 이게 적용이 안되는 것! ... 신기한 건 사방 라운딩 xml 파일은 아주 쉽게 기본 방법으로 제대로 적용이 되었다 ^^... 아랫 부분만 라운딩 된 걸 인식을 못하더라... 아마도 height 문제인 것 같은데, FrameLayout으로도 감싸보고, Relative, Constraint..
statusBar 색상, 텍스트 색상 변경
BottomNavigationView + TabLayout + ViewPager2 모두 이용해서 화면 만들기 (Kotlin) 먼저, BottomNavigationView를 만들어준다. 2020/12/11 - [안드로이드/앱 개발] - BottomNavigationView, Fragment BottomNavigationView, Fragment activity_main.xml color/bottom_navigation_color.xml menu/item_navigation.xml HomeFragment class HomeFragment : Fragment.. jsue.tistory.com BottomNavigation의 menu를 5개 만들었으므로, 각각의 Fragment 또한 5개를 만들어준다. 그 중 SearchFragment에서 TabLayout을 구현하고, 거기에 더해서 ViewPager를 이용해서 슬라이드로 탭 변경도 ..
TabLayout TabLayout을 이용해 상단 탭 만들기 TabItem을 이용하여 탭의 항목을 추가한다. values/styles.xml styles.xml에서 indicator와 텍스트의 색상을 변경할 수 있다. app:tabIndicatorFullWidth="false"를 추가해주면 indicator의 넓이를 텍스트의 길이에 맞게 조절할 수 있다.
BottomNavigationView, Fragment activity_main.xml color/bottom_navigation_color.xml menu/item_navigation.xml HomeFragment class HomeFragment : Fragment() { companion object { fun newInstance() : HomeFragment = HomeFragment() } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } override fun onAttach(context: Context) { super.onAttach(context) } override fun onCreateView( inflater: LayoutIn..
UI 디자인 참고자료 컬러 조합 webgradients.com/ Free Gradients Collection by itmeo.com Free collection of 180 background gradients that you can use as content backdrops in any part of your website. webgradients.com uigradients.com/#Reef uiGradients - Beautiful colored gradients uiGradients is a handpicked collection of beautiful color gradients for designers and developers. uigradients.com color.adobe.com/ko/create/col..