i am designing an application which have diff types of functionalies through buttons/image buttons. At final the list might increase. i want to put one custom home button which always keeps on screen when i am in diff activities.
or either if you have any idea about how this Home button is coded to this layout
below screen. please help.
Have you considered the Action Bar which is exactly designed for this purpose?
http://developer.android.com/guide/topics/ui/actionbar.html
While the home button at the bottom can be easily achieved using an image view/button,Using an action Bar is the recommended option.Not only can you link with the home activity but also any other activity of your choice.Refer this to gain a deeper insight.
http://developer.android.com/guide/topics/ui/actionbar.html
http://developer.android.com/reference/android/app/ActionBar.html
You can either place a button/image button/image anything in xml layout and set on click listener on that component. You can also use option menu and give multiple option on all the screens of your application.
Make a layout with a ScrollView on top, and your image-button below the scrollview.
Example:
<!-- language: lang-xml -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Your Content Here"
/>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
/>
</LinearLayout>
</LinearLayout>
It looks like this:
Related
I am trying to make a layout simulating a Dialog.
I am inserting a ListFragment in my fragment container in this layout. I'm trying to accomplish two things:
Buttons always visible on the bottom of the layout
The layout does not take up the entire height of the screen.
But nothing I try seems to work.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="400dp"
>
<FrameLayout
android:id="#+id/dialog_fragment_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/dialog_button_container"/>
<LinearLayout
android:id="#+id/dialog_button_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button3"/>
</LinearLayout>
</RelativeLayout>
It always wants to take up the entire height of my screen no matter what I do.
I dont exactly understand what you really want to do but I think the first thing to check out is PopupWindow. It pops up like a normal Dialog but you can completly customize its layout and of course the buttons too. You said you want to
"synthesize" it. Im sure it is not that hard to find the right dimens, fontsize and so on for the buttons. Mostly its all set to the default.
If you want your activity's layout to be look like dialog you can use following lines in your manifest file:
<activity
android:name="Your activity name"
android:theme="#android:style/Theme.Dialog" />
I'm currently trying to place a progress bar on the top left corner of my screen. However, I'm not quite sure which way is the best way to do it. Should I create a progress bar programatically instead of creating it in the xml? Or should I change my layout around? Thanks. XML below.
XML CODE:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_marginBottom="5dp"
android:src="#raw/topbar" />
<TextView
android:id="#+id/search_nameOfFeed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="Event Name"
android:textColor="#color/black"
android:textSize="18sp" >
</TextView>
<ListView
android:id="#+id/searchfeed_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.83"
android:dividerHeight="10.0sp"
android:fadingEdge="none"
android:stackFromBottom="false"
android:transcriptMode="normal" >
</ListView>
</LinearLayout>
The best option for layout when you're wanting to position views in specific areas is FrameLayout or RelativeLayout
RelativeLayout will allow you to place each view relative to each other.
FrameLayout allows you to stack views in a z-index positioning.
Play with both and you may come up with results you're looking for.
The best way to design layouts in android is by creating them in XML so you should do it in XML. You can achieve what you want by adding your ProgressBar before your ImageView
I doubt this is what you're looking for exactly, but another way you might want to implement a non-intrusive progress bar is to put it in the title bar of the activity. Check out this for an example of how to do this.
You can create it either way (In XML or Programatically). If you created it progamatcially, set the gravity to top and if you are creating in XML, use Relative Layout instead of Linear Layout and use android:layout_gravity="top|left". If you want to show it at the center follow the link
I must make a layout with 2 overlapping ScrollViews. One is an article with a "see comments" button. The other view is transparent and contains the comments, and is shown on top of the article when the "see comments" button is clicked. The problem is that when the comments are shown and do not fill the screen, touching the screen out of the screen (eg. below the button "Retour" on the image shown below. This is an iphone screenshot, the design on android is different) scrolls the article.
Also, the "Voir les Commentaires" button can be clicked, even with another layout on top of it.
Why is the view below not disabled (button, scroll...) when there's another one on top of it? How can it be done?
Anybody can help?
<?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:background="#FFFFFF">
<RelativeLayout android:id="#+id/header"
android:layout_width="fill_parent" android:layout_height="49dp"
android:background="#e7e7e8">
<!-- header -->
</RelativeLayout>
<ScrollView android:id="#+id/article_scroll"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_below="#id/header">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<!-- article -->
</LinearLayout>
</ScrollView>
<LinearLayout android:layout_width="fill_parent"
android:layout_below="#id/header" android:layout_height="fill_parent"
android:orientation="vertical" android:background="#50000000" android:visibility="gone">
<ScrollView android:id="#+id/comment_scroll"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<!-- comments -->
</ScrollView>
</LinearLayout>
</RelativeLayout>
You should definitely use a new Activity for your comment and use Transucent theme:
<activity android:theme="#android:style/Theme.Translucent">
http://developer.android.com/guide/topics/ui/themes.html
Some alternatives Themes should fit your needs (Dialog for instance)
or a blurried background: http://www.stealthcopter.com/blog/2010/01/android-blurring-and-dimming-background-windows-from-dialogs/
As for the button "Voir les Commentaires", you could set it to enabled = false when the second layer is visible. And I'm not quite sure atm, but I think you can do the same for the bottom ScrollView.
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
I am developing an application and I would like to use the control that I can see in the Photos application and the Desk Clock (on an HTC Desire).
The one I am referring to is the bar along the bottom of the screen that has various icons in it. When you press on an icon, the bubble moves along the bar to the icon you have pressed and the icon is then shown in colour.
What is the name of this control?
The first control you are talking about is the SlidingDrawer, (here is an example of how to use it), then you can just use a GridView if you also want to show icons on there.
If you want to give it a try, you just have to create an XML layout as this:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF4444CC"
>
<SlidingDrawer
android:id="#+id/drawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:handle="#+id/handle"
android:content="#+id/content">
<ImageView
android:id="#id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/tray_handle_normal"
/>
<Button
android:id="#id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="I am big :D"
/>
</SlidingDrawer>
</FrameLayout>
I think you are looking for the Sliding Drawer.