本文介绍了如何使用CustomSliding抽屉像Android应用程序状态栏通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是新的Andr​​oid应用程序想提出其中有NFC技术的应用程序,在这里我要做出这样默认的操作系统状态栏通知一个通知栏。
我现在做它的自定义我想这是调用/在所有屏幕显示,而最终用户从顶部的应用程序内拉至底部。

这是我自定义的滑动抽屉类,并在main.xml中的文件使用它我

 < com.abc.xyx.customnotification.CustomDrawer
    的xmlns:我=htt​​p://schemas.android.com/apk/res/com.abc.xyx.app
    机器人:ID =@ + ID /抽屉
    我:方向=topToBottom
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    我:拉手=@ + ID /句柄
    我:CONTENT =@ + ID /内容
    机器人:layout_marginTop =100dp
    >
    <包括
        机器人:ID =@ ID /内容
        布局=@布局/滑块/>
    < ImageView的        机器人:ID =@ ID /处理
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =150像素
        机器人:知名度=隐形        机器人:SRC =@绘制/ tooltiparea/>
< /com.abc.xyx.customnotification.CustomDrawer>


解决方案

你应该使用哎呀

首先要延伸android.app.Activity一个BaseActivity。现在,你想显示状态栏,这将是您的所有应用程序的活动的父活动。定义所有与该自定义状态栏和有关儿童Ativity

持有的观点父布局功能

有关BaseActivity XML布局会是这样

 < com.abc.xyx.customnotification.CustomDrawer
    的xmlns:我=htt​​p://schemas.android.com/apk/res/com.abc.xyx.app
    机器人:ID =@ + ID /抽屉
    我:方向=topToBottom
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    我:拉手=@ + ID /句柄
    我:CONTENT =@ + ID /内容
    机器人:layout_marginTop =100dp
    >
    <包括
        机器人:ID =@ ID /内容
        布局=@布局/滑块/>
    < ImageView的        机器人:ID =@ ID /处理
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =150像素
        机器人:知名度=隐形        机器人:SRC =@绘制/ tooltiparea/>
< /com.abc.xyx.customnotification.CustomDrawer>
<&RelativeLayout的GT;
这种布局是用于抱着孩子活动的意见
< / RelativeLayout的>

生成accesser方法来访问slidingdrawer和parentLayout。

现在你的活动中,要添加customSlidingBar应该从BaseActivity以这种方式延伸,你只需要code一次滑动抽屉implemation

希望它能帮助

am new to android apps am making an app Which has NFc technology,here i want to make a Notification bar like default OS statusbar Notification.i made it custom now i want it to be call/display in all Screen while end user pull it from top to bottom within the app.

this is my custom Sliding drawer class and am using it in Main.xml file

<com.abc.xyx.customnotification.CustomDrawer
    xmlns:my="http://schemas.android.com/apk/res/com.abc.xyx.app"
    android:id="@+id/drawer"
    my:direction="topToBottom"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    my:handle="@+id/handle"
    my:content="@+id/content"
    android:layout_marginTop="100dp"
    >
    <include
        android:id="@id/content"
        layout="@layout/slider"/>
    <ImageView

        android:id="@id/handle"
        android:layout_width="wrap_content"
        android:layout_height="150px"
        android:visibility="invisible"

        android:src="@drawable/tooltiparea" />
</com.abc.xyx.customnotification.CustomDrawer>
解决方案

you should use oops for that

first make a BaseActivity which extends android.app.Activity. Now this will be the parent Activity for all of your app's Activities where you want to display status bar. Define all the function related to custom status bar in that and a parent layout for holding views related to child Ativity

xml layout for BaseActivity will be like this

    <com.abc.xyx.customnotification.CustomDrawer
    xmlns:my="http://schemas.android.com/apk/res/com.abc.xyx.app"
    android:id="@+id/drawer"
    my:direction="topToBottom"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    my:handle="@+id/handle"
    my:content="@+id/content"
    android:layout_marginTop="100dp"
    >
    <include
        android:id="@id/content"
        layout="@layout/slider"/>
    <ImageView

        android:id="@id/handle"
        android:layout_width="wrap_content"
        android:layout_height="150px"
        android:visibility="invisible"

        android:src="@drawable/tooltiparea" />
</com.abc.xyx.customnotification.CustomDrawer>


<RelativeLayout >
this layout is used for holding child Activities views
</RelativeLayout>

generate accesser method to access the slidingdrawer and parentLayout.

now your activities in which you want to add customSlidingBar should extends from BaseActivity in this way you only have to code once for sliding drawer implemation

hope it helps

这篇关于如何使用CustomSliding抽屉像Android应用程序状态栏通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:35