久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

Badge on Android TabHost

 Mave_tan 2015-12-17

This is an example of How to add a badge in tab

chat_tab.xml

<RelativeLayout xmlns:android='http://schemas./apk/res/android'    android:layout_width='0dip'     android:layout_height='64dip'    android:layout_weight='1'     android:layout_marginLeft='-3dip'     android:layout_marginRight='-3dip'     android:orientation='vertical'     android:background='@drawable/tab_indicator' >    <ImageView        android:id='@+id/chat_icon'        android:layout_width='wrap_content'        android:layout_height='wrap_content'        android:src='@drawable/chat_icon'        android:layout_centerHorizontal='true'/>    <TextView        android:id='@+id/new_notifications'         android:layout_width='wrap_content'        android:layout_height='wrap_content'        android:layout_alignTop='@+id/chat_icon'        android:layout_toRightOf='@+id/chat_icon'        android:layout_marginLeft='-8dp'        android:layout_marginTop='0dp'        android:paddingTop='2dp'        android:paddingLeft='5dp'        android:paddingRight='5dp'        android:paddingBottom='2dp'        android:textSize='8sp'        android:textStyle='bold'        android:textColor='@android:color/primary_text_dark'        android:background='@drawable/badge'        android:visibility='gone'/>    <TextView         android:layout_width='wrap_content'        android:layout_height='wrap_content'        android:text='@string/chat'        style='@android:attr/tabWidgetStyle'        android:textColor='@android:color/tab_indicator_text'        android:layout_centerHorizontal='true'        android:layout_alignParentBottom='true'/></RelativeLayout>

This is badge.xml (red circle for notifications background), TextView id:new_notifications background

<?xml version='1.0' encoding='utf-8'?><shape xmlns:android='http://schemas./apk/res/android'       android:shape='oval' >    <stroke android:width='2dp' android:color='#FFFFFF' />    <corners android:radius='10dp'/>    <padding android:left='2dp' />    <solid android:color='#ff2233'/></shape>

Then in the code you can simply do

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);View chatTab = inflater.inflate(R.layout.chat_tab, null);tvNewNotifications = (TextView) chatTab.findViewById(R.id.new_notifications);intent = new Intent().setClass(MainTab.this, Chat.class);tabSpec = tabHost            .newTabSpec('chat')            .setIndicator(chatTab)            .setContent(intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));

As you can see my Relative Layout has a background @drawable/tab_indicator the tab indicator.xml is the framework's standard drawable of the tab,which i got from the sdk,i suggest you should also get it from the folder of the api in sdk as you also need to copy some images from the drawable folders,you can find it your_sdk_drive:\sdk\platforms\android-8

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多