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 google it up, there are quite a few samples with good explanation, like these:
Android SlidingDrawer with Custom View or
Example to implement
SlidingDrawer in XML or
Widget: SlidingDrawer top to bottom
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
Related
In my application I need to use the RecyclerView in two different activities.
I was thinking to extend the layout, because the base layout (the recycler view) is the same for the two activities, but I don't know if it's possible.
With "to extend a layout" I mean something like this:
If this is my base_layout.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/recyclerView">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
I would like to do something like this in my child_layout.xml:
include "base_layout.xml"
<Button
android:id="#+id/btnAddVehicle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+"
android:onClick="launchAddVehicleActivity"/>
so, the activity which uses chid_layout.xml will have got a RecyclerView and a Button inside.
Is it possible to do something like that?
You could create a generic layout, then add it on your layout's activities.
Generic Layout
my_generic_layout.xml
<RelativeLayout
android:id="#+id/generic_layout">
<RecyclerView/>
</RelativeLayout>
Layout's Activities
<RelativeLayout
android:id="#+id/layout_1">
<include layout="#layout/my_generic_layout" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/layout_2">
<include layout="#layout/my_generic_layout" />
</RelativeLayout>
just use this <include layout="#layouts/chid_layout" />
If you want to add the button inside the layout you need to write a Custom Component. See Android Documentation here https://developer.android.com/guide/topics/ui/custom-components.html#compound
Basically you could create a class which inherits from RelativeLayout which inflates base_layout.xml
I need a arc menu like above image but it is not scrolling. I need that i can add more menus and it should come from bottom while scrolling.And these menu will come after a tap on center button. Please help me.
I have a SemiCircularRadialMenu and there are individual fragments for every menu. I am opening fragments on clicking different menu but when I click on fragment, it also covers that SemiCircularRadialMenu. I want that when I click on the fragment, there should be no effect on SemiCircularRadialMenu.
My XML Code is given below (XML)
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<com.touchmenotapps.widget.radialmenu.semicircularmenu.SemiCircularRadialMenu
android:id="#+id/radial_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:padding="5dp" />
Code link for Semi Circular menu http://hasmukhbhadani.blogspot.in/2014/04/radial-menu-semi-circular-radial-menu.html (CIRCULAR OUTPUT SCREEN: is Semi Circular menu )
I'm using a NavigationDrawer as main menu in my app. Some of my fragments use the SlidingPaneLayout.
At the moment, I show the NavigationDrawer on the right and the SlidingPaneLayouton the left, always a little bit visible.
But I would like to have the NavigationDrawer on the left side and the SlidingPaneLayout on the right side (like in Hangouts) always a little bit visible.
Question:
I know how to get the NavigationDrawr to the other side, but I can't find out how (if possible) to move the SlidingPaneLayout to the right side? So that it slides in from the right...
my solution
<android.support.v4.widget.SlidingPaneLayout
android:id="#+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/fragment_main_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginRight="0dp"
android:orientation="vertical" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/card_toast_container" />
<FrameLayout
android:id="#+id/fragment_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- marginLeft: set it to width - 150 in your code!!! -->
<FrameLayout
android:id="#+id/fragment_slider"
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginLeft="0dp" />
</android.support.v4.widget.SlidingPaneLayout>
and use some wrapping methods like for example following, for easier and more readable code:
public boolean isSliderMenuShown()
{
return !mSlidingLayout.isOpen();
}
public static void openSlider(boolean isSliderLeft, MySlidingPaneLayout slidingLayout)
{
slidingLayout.closePane();
}
public static void closeSlider(boolean isSliderLeft, MySlidingPaneLayout slidingLayout)
{
slidingLayout.openPane();
}
Set this to view inside navigation drawer:
android:layout_gravity="left"
you can try keeping it open in the start with:
SlidingPaneLayout sp = (SlidingPaneLayout) findViewById(R.id.spl);
sp.openPane();
Also keep your main content on the left and menu on the right
After my research and test, android.support.v4.widget.SlidingPaneLayout can't swipe out from right to left. The only effect is swiping out from left to right.
No matter whether android:layout_gravity= is start left end or right.
You can achieve that by adding the layout direction for you Slidingpanel layout
layout = (SlidingPaneLayout) findViewById(R.id.sliding_pane_layout);
layout.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
before that make sure you have added a property android:supportsRtl="true" for your manifest file.
Step-1
In order to support RTL in your app, you first need to add android:supportsRtl="true" to the element in your manifest file.
Step-2
Add RTL support in SlidingPaneLayout
android:layoutDirection="rtl"
Step-3
Add LTR support in child views of SlidingPaneLayout
android:layoutDirection="ltr"
<SlidingPane
android:id="#+id/slidingPanelLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="rtl">
<include
layout="#layout/left_drawer"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layoutDirection="ltr" />
<include
layout="#layout/view_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr"
/>
</SlidingPane>
Note: add LTR support in both left_drawer.xml, view_container.xml
I want to create an activity that has sidebar on the left that is not changing between activity transitions (like split view in ios). It seems that I can do this with fragments but I need to add support for devices that is prior to HoneyComb.
I tried using a layout something like below.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout android:layout_width="320dip"
android:layout_height="match_parent"
android:id="#+id/navLay"
>
<ListView
android:id="#+id/navList"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/contentLay"
><ListView
android:id="#+id/contentList"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
</LinearLayout>
But the first list is also updated on activity transition. I want to note that the activity is the same activity except the right list's data source is different. So it would be pretty good if I could save state and content of the left navigation bar while navigating. Any help will be appreciated.
Take a look at Support Package which provides classes for backward compatibility, and includes Fragment class also.
It seems that I can do this with fragments but I need to add support for devices that is prior to HoneyComb.
You can use fragments and some new APIs on those devices. Just use support package.
I have full screen RelativeLayout that contains the following:
1. FrameLayout, full screen, displaying content.
2. LinearLayout, act as a control menu, stay on top of the content #1, must be able to slide or fade in/out on request(I actually have two of these. One at the top of the screen, another at the bottom).
I have the view display correctly, the menu controller slide/fade in and out when menu button pressed. But when I slide and fade the view out, the click action remain. How do I remove this action?
I tried to call menuLayout.setVisibility(View.GONE); but the action remains.
I read some issue with TranslateAnimation but I cannot get it to work.
Can someone tell me how do I fix this? Example would be appreciated.
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000"
android:layout_alignParentLeft="true"
android:gravity="center_vertical"
android:id="#+id/contentFrame"
>
<ViewSwitcher
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/viewSwitch">
<include layout="#layout/main_car" />
</ViewSwitcher>
</FrameLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="43dp"
android:background="#drawable/um_top_bar"
android:layout_alignParentTop="true"
android:id="#+id/topMenu"
android:gravity="top"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/um_btn_home"
android:id="#+id/homeMainBtn" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/exp_menu_btn"
android:id="#+id/menuMainBtn" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF000000"
android:layout_alignParentBottom="true"
android:id="#+id/bottomMenu"
android:gravity="top"
>
<include layout="#layout/menu_bottom" />
</LinearLayout>
Ok, I got it to work at last. For anyone who may face the same problem, here's what I did.
I place empty layer and separate all menu content into separate XML file.
Here's the code:
/** Resetting bottom menu content */
private void resetBottomMenu(boolean isOpen){
bottomMenu.removeAllViews();
bottomMenu.addView(loadBottomMenu(isOpen));
// Control event handler goes here.
}
/** Load bottom menu content from XML */
private LinearLayout loadBottomMenu(boolean isOpen){
LinearLayout result = null;
if(isOpen){
result = (LinearLayout)View.inflate(this.getApplicationContext(), R.layout.menu_bottom_open, null);
}else{
result = (LinearLayout)View.inflate(this.getApplicationContext(), R.layout.menu_bottom, null);
}
return result;
}
Every time I want to slide menu in, I called resetBottomMenu then start animation on bottomMenu. If I want to close the menu, I start animation then resetBottomMenu.
It's important to remove child view in that Layout since that will remove the click action.
P.S. I'm not sure if this is the best way of doing it but I can confirm that it works. I have three menu that need to be fade/slide and they work perfectly now :)