динамически показывать непрочитанные уведомления в нижнем колонтитуле Android?

мое требование состоит в том, чтобы показать количество непрочитанных уведомлений в нижнем колонтитуле следующим образом: http://i.stack.imgur.com/IOaK0.jpg

Я новичок в Android, и я действительно понятия не имею, как этого добиться, я гуглил для этого, но не получил результатов.

это мой нижний колонтитул.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/footer_1"
    android:layout_width="fill_parent"
    android:layout_height="56dp"
    android:layout_alignParentBottom="true"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:background="@color/footer_bg"
        android:clickable="true"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/footer_background"
            android:clickable="true"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:padding="5dp" >

            <ImageView
                android:id="@+id/footer_home_icon"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:clickable="true"
                android:duplicateParentState="true"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:src="@drawable/home_menu" />

            <TextView
                android:id="@+id/footer_home"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:duplicateParentState="true"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:text="@string/footer_home"
                android:textColor="@drawable/footer_text"
                android:textSize="@dimen/footer_text" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/alert_layout"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/footer_background"
            android:clickable="true"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:padding="5dp" >

            <ImageView
                android:id="@+id/footer_alert_icon"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:clickable="true"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:src="@drawable/alert_menu" />

            <TextView
                android:id="@+id/footer_alert"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:text="@string/footer_alert"
                android:textColor="@drawable/footer_text"
                android:textSize="@dimen/footer_text" />
        </LinearLayout>
</LinearLayout>

может кто-нибудь, пожалуйста, скажите мне, как я могу это сделать?

Заранее огромное спасибо!!


person Kumar Subramanian    schedule 02.01.2014    source источник
comment
Можете ли вы отобразить количество значков на вкладке?   -  person M D    schedule 02.01.2014
comment
не в состоянии вас достать? не могли бы вы объяснить мне подробно?   -  person Kumar Subramanian    schedule 02.01.2014
comment
вы говорите о такой структуре: http://stackoverflow.com/questions/8476544/ui-help-for-notification-on-icon/20437659#20437659   -  person M D    schedule 02.01.2014
comment
Спрашиваете, как создать макет, аналогичный показанному на скриншоте, или спрашиваете, как реализовать код? показать счет?   -  person Joel Fernandes    schedule 02.01.2014
comment
в основном я новичок в Android, и я понятия не имею, как это реализовать, если вы покажете несколько примеров реализации, которые помогут мне подобрать то, что может быть здорово .. спасибо   -  person Kumar Subramanian    schedule 02.01.2014


Ответы (1)


Вы можете создать макет, как показано ниже:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer_1"
android:layout_width="fill_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="55dp"
    android:background="@android:color/darker_gray"
    android:clickable="true"
    android:orientation="horizontal" >

    <RelativeLayout
        android:id="@+id/main_widget3"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal|center_vertical"
        android:layout_weight="0.5"
        android:background="@android:color/holo_blue_dark"
        android:focusable="true" >

        <ImageView
            android:id="@+id/icon3"
            android:layout_width="wrap_content"
            android:layout_height="30dip"
            android:layout_centerInParent="true"
            android:layout_marginTop="8dp"
            android:background="@drawable/brisbane"
            android:contentDescription="image"
            android:scaleType="center" />

        <TextView
            android:id="@+id/footer_alert3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/icon3"
            android:clickable="true"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center"
            android:text="Brisbane"
            android:textColor="@android:color/black"
            android:textSize="10dip" />

        <TextView
            android:id="@+id/txt_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="-10dip"
            android:layout_toRightOf="@+id/icon3"
            android:background="@drawable/badge_count3"
            android:contentDescription="badge"
            android:gravity="center"
            android:text="1"
            android:textColor="@color/White"
            android:textStyle="bold"
            android:visibility="gone" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/main_widget2"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal|center_vertical"
        android:layout_weight="0.5"
        android:background="@android:color/holo_blue_bright"
        android:focusable="true" >

        <ImageView
            android:id="@+id/icon2"
            android:layout_width="wrap_content"
            android:layout_height="30dip"
            android:layout_centerInParent="true"
            android:layout_marginTop="8dp"
            android:background="@drawable/bike"
            android:contentDescription="image"
            android:scaleType="center" />

        <TextView
            android:id="@+id/footer_alert2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/icon2"
            android:clickable="true"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center"
            android:text="Bike"
            android:textColor="@android:color/black"
            android:textSize="10dip" />

        <TextView
            android:id="@+id/txt_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="-10dip"
            android:layout_toRightOf="@+id/icon2"
            android:background="@drawable/badge_count3"
            android:contentDescription="badge"
            android:gravity="center"
            android:text="1"
            android:textColor="@color/White"
            android:textStyle="bold"
            android:visibility="visible" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/main_widget"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@android:color/holo_blue_dark"
        android:layout_gravity="center_horizontal|center_vertical"
        android:layout_weight="0.5"
        android:focusable="true" >

        <ImageView
            android:id="@+id/icon"
            android:layout_width="wrap_content"
            android:layout_height="30dip"
            android:layout_centerInParent="true"
            android:layout_marginTop="8dp"
            android:background="@drawable/bowls"
            android:contentDescription="image"
            android:scaleType="center" />

        <TextView
            android:id="@+id/footer_alert"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/icon"
            android:clickable="true"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center"
            android:text="Bowls"
            android:textColor="@android:color/black"
            android:textSize="10dip" />

        <TextView
            android:id="@+id/txt_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="-10dip"
            android:layout_toRightOf="@+id/icon"
            android:background="@drawable/badge_count3"
            android:contentDescription="badge"
            android:gravity="center"
            android:text="1"
            android:textColor="@color/White"
            android:textStyle="bold"
            android:visibility="gone" />
    </RelativeLayout>
</LinearLayout>

badge_count2.xml file

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<solid android:color="@color/red" >
</solid>

<stroke
    android:width="2dp"
    android:color="#FFFFFF" >
</stroke>

<padding
    android:bottom="2dp"
    android:left="7dp"
    android:right="7dp"
    android:top="3dp" />

<corners android:radius="10dp" >
</corners>

добавьте красный цвет в файл string.xml

<color name="red">#e50822</color>

и теперь вы можете видеть или скрывать это представление в соответствии с вашими требованиями. Индивидуальные под себя. Thnx Взгляните на снимок ниже: введите здесь описание изображения

person M D    schedule 02.01.2014