본문 바로가기

안드로이드

(12)
[안드로이드/Kotlin] RecyclerView를 이용한 GridView 생성하기 (GridLayoutManager) 안드로이드에는 격자 형태로 아이템을 보여주는 GridView 라는 위젯이 존재한다. 하지만 GridView를 사용하는 대신 RecyclerView에 GridLayoutManager 를 설정하여 사용할 수 있다. val gridLayoutManager = GridLayoutManager(this, 3) mBinding.recyclerItem.layoutManager = gridLayoutManager mBinding.recyclerItem.adapter = RecyclerAdapter() GridLayoutManager 를 생성할 때 파라미터로 context 와 한 줄에 표시해줄 아이템 수인 spanCount 를 입력하면 된다. GridLayoutManager(this, 3) -> 한 줄에 3개의 아이템을..
[안드로이드/java] BottomSheet 스크롤 할 때 slideOffset 으로 background 조절 int colorFromTop = getResources().getColor(R.color.downy); int colorFromBottom = getResources().getColor(R.color.scooter); int colorTo = getResources().getColor(R.color.transparent); int[] colors = {interpolateColor(slideOffset, colorFromTop, colorTo), interpolateColor(slideOffset, colorFromBottom, colorTo)}; GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, col..
[안드로이드] EditText 키보드 다음/완료 등 엔터 버튼 변경 XML 에서 EditText에 해당 코드 추가 singleLine 이 적용되어야 imeOptions 가 동작한다. android:imeOptions="actionNext" android:singleLine="true" actionNext = 다음 actionDone = 완료 actionGo = 이동 actionSearch = 검색 actionSend = 보내기 actionPrevious = 이전
[안드로이드/java] 문자 수신 감지(BroadcastReceiver) 1. manifest permission 추가 2. Receiver 생성 public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { Bundle bundle = intent.getExtras(); SmsMessage[] message = null; String str = ""; String phoneNumber = ""; if (bundle != null) { Object[] pdus = (Object[]) bundle.get("pdus"); message = new SmsMessage[pdus.length]; for (int i=0; i