Shape를 만든 후
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/buttonColor"/>
<stroke
android:width="1dp"
android:color="@color/transparent" />
<corners
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
<padding
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
</shape>
적용하고자하는 레이아웃에 백그라운드로 적용
<Button
android:id="@+id/btn"
app:backgroundTint="@null"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="@drawable/your_shape"
android:gravity="center"
android:text="@string/login"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold"/>
적용한 액티비티에 아래 코드로 Shape에 색상을 변경하면됨
GradientDrawable bgShape = (GradientDrawable) btn.getBackground();
bgShape.setColor(Color.BLACK);
Drawable bgShape = DrawableCompat.wrap(btn.getbackground()).mutate();
DrawableCompat.setTint(bgShape, ContextCompat.getColor(mContext, R.color.yourColor));
'android' 카테고리의 다른 글
appbarlayout 스크롤 Enable, disable (0) | 2017.11.22 |
---|---|
recyclerview scroll 정보 가져오기 (0) | 2017.11.22 |
문자, 전화 intent (0) | 2017.11.13 |
리스트뷰, 스크롤뷰 리플 이펙트 제거 (0) | 2017.11.07 |
이미지뷰 라운드 처리 (0) | 2017.10.30 |