I'm building a photo effect app for android, and i want to create a menu like Camera360 app's menu (please view menu image link):
How can i create menu like this or support library?
Thanks
You can recreate the menu at the bottom using a ScrollView that holds a row of buttons. The new menu after the click in your image looks like another Activity with the same layout. I recreated a rough version of it like so:
<HorizontalScrollView android:layout_height="50dp" android:layout_width="match_parent" android:scrollbarSize="0dp">
<LinearLayout android:layout_height="50dp" android:layout_width="wrap_content">
<Button android:id="#+id/btn1" android:layout_height="50dp" android:layout_width="50dp" android:text="op1" />
<Button android:id="#+id/btn2" android:layout_height="50dp" android:layout_width="50dp" android:text="op2" />
...
</LinearLayout>
</HorizontalScrollView>
Tinker with the parameters and visuals and you're all set!
In order to make it 'multi-level' you can add onClickListeners that launch an acquitted activity according to your menu tree. For communication between activities, you can use startActivityForResult.
Related
What I need in general: replace(hide) one view with another by a button click
Let's go deep in details:
I use ViewPager, which consists of 100 images.
Layout of ViewPager
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#ffffff" >
</android.support.v4.view.ViewPager>
<ImageButton
android:id="#+id/imagePlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageRight"
android:layout_alignTop="#+id/imageList"
android:src="#drawable/list" />
</RelativeLayout>
Layout of Image
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dip"
android:background="#ffffff">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
It works - no problems. But I need to add button to the viewpager and after tapping image in the viewpager should be changed to the gif. It looks like gifs preview and after onclick play - gif starts to play.
Custom layout for gifs:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageList"
android:layout_marginRight="28dp"
android:layout_toLeftOf="#+id/imageRight" >
<com.basv.gifmoviewview.widget.GifMovieView
android:id="#+id/gif1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
How it should be resolved? It's pretty simple for me to open another activity after tapping to the button, but the issue is to play gif in the same Fragment
Any ideas?
I'd simply add your com.basv.gifmoviewview.widget.GifMovieView somewhere to your root RelativeLayout (perhaps you may need to wrap both ViewPager and GifMovieView in additional FrameLayout) and simply show/hide it when needed using ordinary setVisibility().
EDIT
I suppose it's not the best solution for phones' memory usage
I quickly looked into the sources and there's no much code really. So if you bother memory usage you can always dynamically create widget prior showing it (and destroy once hidden) or, as I cannot see the method to "unload" a GIF, you can always use "1x1 px" empty Gif to ensure last one you just stopped showing is no longer occupying precious memory if not needed.
Here is an idea. Make that layout with both view pager and gif but the gif visibility set to invisible so that initially its there but not visible. But when someone click the button you should put that gif to life in code by setting it to visible while also changing view pager to invisible or gone in case you dont even want its initial boundary being present!!
I need to create multiple activities that will have a bar at the bottom of the screen. This bar contains three functions that are common to the activities. Can i keep the bar constantly on screen and switch through activities?
One way could be to load different fragments on the same activity, and let the bar be below the fragments.
But is it possible to switch between activities, without recreating the bar every time a new activity opens?
Possible option:
You have to create bottom layout bottomlayout.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/toolBarText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:background="#android:color/transparent"
android:layout_centerInParent="true"
android:text="TOOLBAR TEXT"
android:textColor="#FFFFFF"
android:textSize="15dp" />
</RelativeLayout>
Include bottomlayout in every xml layout of activity.
<include layout="#layout/bottomlayout"/>
Fragments, is one way of doing it. Isn't there any other.
I'm making custom view for an Action Bar. There have to be centered title, some action buttons at the right and navigation drawer button/back with title at the left.
I use RelativeLayout to place all elements, like so (this is demonstrating variant of real layout):
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/actionBarHomeContainer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:clickable="true">
<ImageView
android:id="#+id/actionBarHomeImage"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:duplicateParentState="true"/>
<TextView
android:id="#+id/actionBarHomeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:duplicateParentState="true"/>
</LinearLayout>
<TextView
android:id="#+id/actionBarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
<LinearLayout
android:id="#+id/actionBarOptionsContainer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_alignParentRight="true">
<!--Action items will be added here pragmatically-->
</LinearLayout>
</RelativeLayout>
In most screen cases it's all OK (green picture), but when I deal with tight screens, my title is overlapping by home label (yellow picture). Keep in mind the this is only demonstrating situation, real items smaller than drew ones and case like this is rare. So my aim is in case of title is overlapped just place it in center of remain space between actionBarHomeContainer and actionBarOptionsContainer (blue picture). Is it possible somehow and what other solutions you may suggest to me?
Thanks.
There's an official and very easy solution to your problem: Don't mimic UI elements from other platforms
Don't use labeled back buttons on action bars
Other platforms use an explicit back button with label to allow the user to navigate up the application's hierarchy. Instead, Android uses the main action bar's app icon for hierarchical navigation and the navigation bar's back button for temporal navigation. For more information, please review the Navigation pattern.
Follow this guideline to provide a consistent navigation experience across the platform.
Android action bar with up caret vs. iOS labeled "Back" button.
i would like to create a flexible user interface for the android platform.
basically my layout would consist of a image button with at "plus" sign at the beginning.
when teh user clicked it. another layout is called where the user is prompt to name the image button that is suppose to be created.When the user clicks confirm, he'll e brought back to the 1st layout and the newly added image button would replace the position of the "plus" sign image button and the plus sign image button would shift to the right.
i know how to create the layout initially but i dunno how to programmed it to function the way i described above.
ok so now i have my main layout file set this way:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#000000" >
<ImageButton
android:id="#+id/addRoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="25dp"
android:layout_marginTop="38dp"
android:background="#80000000"
android:src="#drawable/plus" />
<TextView
android:id="#+id/textView1"
android:layout_width="#+id/addRoom"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/addRoom"
android:layout_alignRight="#+id/addRoom"
android:layout_below="#+id/addRoom"
android:text="#string/add_room"
android:gravity="center"
android:textColor="#FFFFFF" />
</RelativeLayout>
</ScrollView>
would i have any issues when i include the fragments to shift the image button and textview when the alignment instructions to both of it.
When you want to manipulate your activity's UI in real time by the user it's recommended to use Fragments and Fragment Manager to change diffident parts of your activity's view.
You can find great information in the docs:
http://developer.android.com/guide/components/fragments.html
or
http://marakana.com/s/post/1250/android_fragments_tutorial
in your case you would do some thing like that:
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.remove(plusButtonFragment)
.add(R.id.containerForFragments,userNewFragment)
.add(R.id.containerForFragments, plusButtonFragment)).commit();
after you have created the plusButtonFragment and the userNewFragment.
Update:
For managing the fragments location in a relative layout check out the next post:
How to add fragments programmatically in relativelayout
Does anyone know how to make a floating menu like the ones in Angry Birds home screen?
Here is a picture showing the menu buttons in collapsed mode (gear, up buttons). On tapping these buttons, the actual menu would expand, showing two or more round buttons.
Any links, clues is much appreciated.
I might be wrong but I think that the entire thing is done in OpenGL.
I guess it's an image with a transparent background and you calculate its position based on time....
Although you could achieve it with standard widgets, maybe it would be a better idea to create a custom view and implement onDraw()
This is done within the XML of your 'game screen.' Assuming you've done a tutorial on OpenGL-ES, you should have an xml file that holds your custom GLSurfaceView. To add overlay items like buttons and, well.. anything, just add them to this xml file. Here's an example of a game I'm working on:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
//This is your GLSurfaceView which will fill the whole screen
<android.opengl.GLSurfaceView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/GLSurface" />
//This layout will overlay the game
<LinearLayout
android:gravity="center"
android:weightSum="100"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_weight="10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sel"
/>
<SeekBar
android:paddingLeft="30px"
android:paddingRight="30px"
android:layout_weight="80"
android:gravity="center"
android:id="#+id/RotateBar"
android:layout_width="180px"
android:layout_height="wrap_content"
android:max="180"
/>
<Button
android:layout_weight="10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Act"
/>
</LinearLayout>
Obviously this is modified (I don't have buttons floating in the center of the screen :P ) but you get the idea. Here's a link to good OpenGL-ES tutorial: link