728x90
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, colors);
gd.setCornerRadii(new float[]{radius, radius, radius, radius, 0, 0, 0, 0});
act.layoutIntroPeek.setBackground(gd);
background 가 gradient 도 있고 상단 corner도 있어서 작업하였다.
참조한 코드
https://android.jlelse.eu/choreographic-animations-with-androids-bottomsheet-fef06e6ecb81
Choreographic animations with Android’s BottomSheet
It has been a while since Google included bottom sheets into its design support library allowing developers to integrate it into their…
android.jlelse.eu
private int interpolateColor(float fraction, int startValue, int endValue) {
int startA = (startValue >> 24) & 0xff;
int startR = (startValue >> 16) & 0xff;
int startG = (startValue >> 8) & 0xff;
int startB = startValue & 0xff;
int endA = (endValue >> 24) & 0xff;
int endR = (endValue >> 16) & 0xff;
int endG = (endValue >> 8) & 0xff;
int endB = endValue & 0xff;
return ((startA + (int) (fraction * (endA - startA))) << 24) |
((startR + (int) (fraction * (endR - startR))) << 16) |
((startG + (int) (fraction * (endG - startG))) << 8) |
((startB + (int) (fraction * (endB - startB))));
}
300x250
'개발 > Android' 카테고리의 다른 글
[안드로이드/Kotlin] RecyclerView를 이용한 GridView 생성하기 (GridLayoutManager) (0) | 2022.05.26 |
---|---|
[안드로이드/java]scrollview 안에 recyclerview 스크롤 문제 (0) | 2019.08.02 |
[안드로이드] TextView 한 줄만 표시하기 (뒷 부분 ... 으로 생략) (0) | 2019.01.16 |
[안드로이드/java] 안드로이드 웹뷰 캐시 삭제 (0) | 2019.01.07 |
[안드로이드] EditText 키보드 다음/완료 등 엔터 버튼 변경 (0) | 2019.01.03 |