Is there any sliding menu with visible column before click? - layout

I've searched but no result.
I would like have menu where you see still column and when you click on it, it will slide right or left showing the rest of layout. What is more it should slide over my activity.
Any help?
I'm looking for something like that:
I found sliding menu from jfeinstein only but when you swipe, your screen is moving also.
Thanks in advance.

This is probably what you need.
Example:
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<shared.ui.actionscontentview.ActionsContentView
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:actions_layout="#layout/actions"
app:actions_spacing="50dp"
app:content_layout="#layout/content"
app:shadow_drawable="#drawable/shadow"
app:shadow_width="8dip"
app:spacing="64dip"
app:spacing_type="right_offset" />
</RelativeLayout>
app:actions_layout="#layout/actions" - this is the layout for your left side menu. You can put there everything you want
app:actions_spacing - offset from left side in dp - that means how much the left menu will be visible
app:content_layout="#layout/content" - this is the layout for main content. You can also put there everything. For example there you can have a FrameLayout and you can attach a fragment from code based on what menu item a user clicked
app:spacing_type="right_offset" and app:spacing="64dip" - that means that when left menu is opened, then how much the main content will be visible
MainActivity.java:
#Override
protected void onCreate(Bundle savedInstanceState)
{
setContentView(R.layout.activity_main);
mSlidingMenu = (ActionsContentView) findViewById(R.id.content);
//this will open menu
mSlidingMenu.showActions();
//this will close menu
mSlidingMenu.showContent();
}

Related

AppCompatActivity with Toolbar: menu items not showing on Toolbar

scratching my head. if someone could help that would be great. I am switching from extends ActionBarActivity to extends AppCompatActivity with Toolbar and need help displaying items on toolbar.
I am using extends AppCompatActivity included android.support.v7.app.AppCompatActivity; then inside onCreate() have:
Toolbar jobListToolbar = (Toolbar) findViewById(R.id.job_list_toolbar);
setSupportActionBar(jobListToolbar);
then in xml file I have
<android.support.v7.widget.Toolbar
android:id="#+id/job_list_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
then in menu file I have items and everything seems to work, however not the way I want.
Toolbar/ActionBar is displayed on top of the screen, but no menu items showing on it. If I press phone original menu button then onCreateOptionsMenu(Menu menu) is initiated for the first time, and menu is showing. But it shows just above this phone button. But I want those buttons to show on Toolbar/ActionBar on top of the screen. I read somewhere that if phone has hardware menu button it will not show menu items in Toolbar/ActionBar, but I had it somehow done with extends ActionBarActivity, but there should be a way to do this with extends AppCompatActivity. Need to move to newer recommended way by google, but not sure how to show items on that Toolbar/ActionBar on the top of the screen.
After a day of research on how to switch to AppCompat Toolbar finally found the solution. Two must do steps (No 2 being the one that nobody talks about):
I.) couple good resources on how to set up Toolbar can be found in this video Toolbar Tutorial and also in this StackOverflow: toolbar button
II.) MAKE SURE YOU PLACE THIS CODE AT THE BOTTOM OF onCreate():
toolbar= (Toolbar) findViewById(R.id.job_list_toolbar);
setSupportActionBar(toolbar);
if(getSupportActionBar()!=null) {
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
My problem was that I had some code in onCreate() that modified the toolbar buttons. That code needed to be run before toolbar was opened. If only first two lines of the code above included toolbar will show, but no menu will be inflated and no buttons. When I called getSupportActionBar().setDisplayShowHomeEnabled(true); thats when onCreateOptionsMenu(Menu menu) is called (if no true enabled it is not called), also make sure you have getMenuInflater().inflate(R.menu.job_list, menu); inside onCreateOptionsMenu(Menu menu).
If the code that calls for menu to open getSupportActionBar().setDisplayShowHomeEnabled(true); is not at the end of onCreate() you might be scratching your head why the menu is not showing. So make sure you execute your relevant onCreate() code before you call the menu to open.
MyActivity:
extends AppCompatActivity
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarhome);
setSupportActionBar(toolbar);
activity_my.xml: If you want you can delete the last line 0 ep. They are the starting point of 0 to launching toolbar
<android.support.v7.widget.Toolbar
android:id="#+id/toolbarhome"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:titleTextAppearance="#style/Toolbar.TitleText"
app:layout_collapseMode="pin"
android:background="#color/colorPrimary"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
android:contentInsetRight="0dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp" >
//designed the way you like
</android.support.v7.widget.Toolbar>
manifest:
<activity
android:name=".MyActivity"
android:theme="#style/AppTheme.NoActionBar"/>
style:
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"> </style>
<style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">italic</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

android app side menu like google map menu

I am looking to put side menu similar to "google map" side menu which appears next to "Search Google Maps" you click on the icon and you get menu
is there any framework to implement ?
spending much time but can't find out how
can any expert advise/suggest/help me
I would appreciate your help very much
What you are looking for is navigation menu with layout_gravity="start".
Declare your layout like as shown below:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer_layout"
tools:context=".MyActivity">
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/navigation_view"
android:layout_gravity="start">
//put your menu items here...
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
If u want to see the hamburger icon as well then use the code below:
actionBarDrawerToggle=new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
drawerLayout.setDrawerListener(actionBarDrawerToggle);
and override onPostCreate as:
#Override
protected void onPostCreate(Bundle savedInstanceState){
super.onPostCreate(savedInstanceState);
actionBarDrawerToggle.syncState();
}
Let me know if this is not enough for you...

TextView in ToolBar moving to right on setDisplayHomeAsUpEnabled(true)

I am new to Android app development and using Android studio. I want to place a Textview in ToolBar. Here is my code of ToolBar xml file:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF5722"
android:elevation="4dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Holler"
android:textColor="#android:color/white"
android:textStyle="bold|italic"
android:textSize="30dp"
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:gravity="center"
/>
</android.support.v7.widget.Toolbar>
On my first activity it is showing as expected in centre. But when I launch new Activity the TextView is moving to bit right. Here is my code for FirstActivity:
toolbarHome = (Toolbar) findViewById(R.id.tool_bar_home); // Attaching the layout to the toolbar object
setSupportActionBar(toolbarHome);
final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeAsUpIndicator(R.mipmap.ic_launcher);
actionBar.setDisplayHomeAsUpEnabled(true);
}
Please let me know if you require more code.
It is the default behaviour of toolbar. It is because of the margins of the back button. If it is a simple text, you can use the toolbar title to set a textview.
But if you want to use your textview in the toolbar. You want to hide the back button by calling :
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
Now you have to create your own back button by setting a ImageButton/ImageView with back arrow icon in the layout file along with your TextView to achieve the desired results.

`VideoView.start()` cause other views to break

When my activity receives a new intent via onNewIntent, it updates the data of three Views, an ImageView, a TextView, and a VideoView. The problem is, the two other views just flash, then disappear when my VideoView comes on. After scattering a few breakpoints, I discovered that they appear when their content is set, but disappear when VideoView.onStart() is called in my MediaPlayer.onPrepared() method. I also have an AlertDialog show up when the menu button is pressed. After pressing the menu button, it shows up. I'm on Android API 9, as this is the API on the device I'm working on. I really need help, so I'd appreciate any advice.
Here's the layout. I don't think it's the issue though:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true" >
<TextView
android:id="#+id/marquee"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:ellipsize="marquee"
android:focusable="false"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="#android:style/TextAppearance.Large"
android:textColor="#android:color/white" >
</TextView>
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="#id/marquee"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical" />
<VideoView
android:id="#+id/video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/marquee"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="#+id/image" />
</RelativeLayout>
Take note that the TextView is meant to be a marquee; it's supposed to keep scrolling sideways, until it is disposed of. I discovered that when the text is too short for it to start the marquee, the TextView AND the ImageView disappear (as stated earlier, they appear for a split second, then disappear). However, when the text causes the marquee feature to activate, everything works.
CURRENTLY:
I got it to work by calling postInvalidateDelayed(500) on my ImageView and TextView after calling VideoView.start(). I think the start() method is causing the problem, and requires that other views call invalidate(). Also, for some reason, there needs to be a small delay in-between the call to start() and the call to invalidate().
The layout is the issue.
Your VideoView is declared as match_parent, match_parent, allowing it to consume the whole width and height of the screen. Since you declared it last on the xml file (You used RelativeLayout. Ordering matters), the TextView and the ImageView would be covered by the VideoView.
If you're confused,
match_parent is basically the same as fill_parent. It's just another name for fill_parent in android 2.3+
Now what can you do about it?
Reorder your views in such a way that the largest is declared first. In this case, VideoView, then ImageView, then TextView.
Also note that your ImageView has height set to fill_parent - you may not want that.
I created a method, but it seems very bad:
private void startVideo() {
this.videoView.start();
if (this.imageView != null)
this.imageView.postInvalidateDelay(500);
if (this.textView != null)
this.textView.postInvalidateDelay(500);
}
It works, but it makes me feel dirty.

How to create clickable icons on the Custom Title Bar

I want to create the click effect on the following type of custom title Bar.
There are three functions in here:Home,Title and Search, clicking either of it should perform the further function.
I was following this
http://staticallytyped.wordpress.com/2011/03/18/android-dynamic-and-custom-title-bars/
But i want the effect which i have posted above.
The thing you are talking about is called Action Bar. This is specially designed for Android Tablets. But developers have made Action Bar available for Android Mobile Phones too.
Have a look at Action Bar written by johannilsson. You can simply download this library project and customize according to your need and then integrate this library to your project.
Other Action Bar examples :
Xoriant Action Bar --
Note : THIS IS THE SAME THING THAT YOU WANT as you want to have Home, Search and Title on it.
Thiranjith blogspot
Just try this..
1) First create two layouts like main & custom_title
2) You must include the drawables which type like you've posted here. And, use this code.
main.xml - Just designed whatever you want.
custom_title.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:gravity="center_vertical"
android:paddingLeft="5dip"
android:background="#323331">
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="hello"
android:text="Button" />
</LinearLayout>
Main.java
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
}
public void hello(View view)
{
Toast.makeText(getApplicationContext(), "Hi, this is test.", Toast.LENGTH_LONG).show();
}
Change this code to your needs. Hope this helps you.

Resources