2011-03-25 8 views
0

탭을 위해 iPhone 배지와 같이 안드로이드 탭 표시 줄에 알림을 추가 할 수 있습니까? 나는 알림을 의미하지는 않습니다. 여기에 iPhone 배지 스크린 샷도 게재 할 것입니다. enter image description here안드로이드 탭 바

안드로이드에서 배지를 사용할 수없는 경우 탭 모음 앞에보기를 배치하는 것이 좋습니까?

+4

이전 질문 중 일부에 동의 할만한 답변이있을 수 있습니까? – Nanne

+0

이것은 안드로이드에서하는 것은 매우 쉽습니다. 내 대답을 확인하십시오. http://stackoverflow.com/a/16359798/1939564 –

답변

1

탭에 배지 또는 작은보기를 추가 할 수 없습니다. 그러나 사용자 지정 탭을 만들고 모든보기에서 해당 탭을 추가 할 수 있으며 모든 활동에서 setContentView()를 재정의하고 내용보기를 설정하기 전에 사용자 지정 탭을 처리 할 수 ​​있습니다.

2

Android Project에 android-viewbadger.jar을 포함시킨 다음 BadgeView 개체를 사용하는 것이 가능합니다.

0

사용자 정의 탭 항목 xml을 만들고 RelativeLayout에 배경 이미지와 centerInParent textView를 배치 할 수 있습니다. RelativeLayout의 가시성을 GONE으로 설정하고 표시하려면 언제든지 표시하고 원하는 텍스트로 설정하십시오. 또한

<RelativeLayout 
     android:id="@+id/tabBadge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="47dp" 
     android:layout_marginTop="10dp" 
     android:layout_toStartOf="@+id/tabTitle" 
     android:visibility="gone" > 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:background="@drawable/basket_item" 
      android:contentDescription="@string/action_settings" /> 

     <TextView 
      android:layout_centerInParent="true" 
      android:id="@+id/tabBadgeText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:textColor="#ffffff" 
      android:textSize="10sp" /> 
    </RelativeLayout> 

당신이 원하는 때마다 당신이 그것에 접근 할 수 있도록 아래의 코드와 같은 태그를 생성하는 동안 코드에 RelativeLayout의 것을 설정해야합니다에 :

// mTitle is the title of the tab 

if (mTitle.equalsIgnoreCase("Basket")) { 

//count is the TextView inside your badge 

count = (TextView) view.findViewById(R.id.tabBadgeText); 

//layout is the whole badge's layout 

layout = (RelativeLayout) view.findViewById(R.id.tabBadge); 

} 

는이 경우 도움이되기를 바랍니다 자세한 정보가 필요하면 언제든지 물어보십시오.