에서 탐색 항목에 여백을 추가 like :내가 같이 인스턴스화 <code>BottomNavigationView</code>이 BottomNavigationView
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFF0"
android:pathData="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"
android:strokeColor="#FFFFF0"
android:strokeWidth="1" />
</vector>
위에서 볼 수 있듯이 navigat의 버튼 주위에는 테두리가 있습니다. 그러나 이온 아이템은 국경이 서로 닿아 있습니다. 따라서 나는 메뉴 버튼 사이에 여백을 추가하고 싶습니다. 어떻게해야합니까? 당신은 또한 스크린 샷에서 볼 수 있듯이
, 나는 모드로 이동 방지하고 있습니다. 전화로이 작업을 수행합니다.
BottomNavigationViewHelper.removeShiftMode(navigationView);
here 코드를 사용하십시오. 버튼 주위
경계는 다음과 같이 추가되었습니다 stateListDrawable
다른 메뉴 버튼을 누를 때 변하는 StateListDrawable
지칭
int stateListDrawable = drawableStateLists.get(currentFragment);
navigationView.setItemBackgroundResource(stateListDrawable);
있다. StateListDrawable
예를 들어, 결과적으로이 같은 XML 형태를 참조하는 XML 선택을 의미한다 : - 삽입
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp"/>
<stroke
android:width="2dp"
android:color="@color/intro"/>
</shape>
어떻게 그 테두리를 추가 했습니까? – azizbekian
@azizbekian 제 편집을 참조하십시오. – kalabalik