How to achieve below type of UI, It has one home up button and and imageView. I don't want to use coordinate layout as this whole page scrolls up instead of collapsing image.
Home up button overlaps entire image
Did you try with linear layout only for that part.
You can try like this
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#drawable/profile_img" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_arrow" />
</FrameLayout>
Related
Quick background: I have a portion of my activity in a relative layout. I did this on purpose because I wanted a button directly below a listview. I want the button to move down as the listview expands which is why I set it up this way. I've set the height of the listview to wrap content, this way in the relative layout, the button will move down as the list expands.
Issue: Once the list gets big enough such that the content fills up the screen, the button remains below the list (which is fine) but I can't scroll down the list to reveal the button. The button "disappears" below the list. How can I make it so that I can scroll on the list/screen to reveal my button?
Edit: I do want the button to go off screen, I just want to be able to scroll down to see it again.
Sample code below + images:
3 pics, one showing the intial layout, next you can see the button moves as my list expands, 3rd, eventually the button reaches the bottom and I can't scroll more to click it.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/workoutList"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/logExerciseButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/workoutList"
android:text="#string/log_set" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/workoutList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/logExerciseButton" />
<Button
android:id="#+id/logExerciseButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/log_set" />
</RelativeLayout>
wrap your ListView with ScrollView:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/workoutList"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
<Button
android:id="#+id/logExerciseButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/scrollView"
android:text="#string/log_set" />
</RelativeLayout>
Adding the button as a footer to the listview resulted in the desired behavior: https://www.tutorialspoint.com/how-to-add-footer-in-android-listview
Sorry for the elementary question but I can't find the solution:
When covering a button with a layout without elevation, it emerges over the layout because a button has a depth (negative depth, it points at the viewer).
So, if you have a
<FrameLayout... >
<Button.../>
<FrameLayout
id="#+id/fragmentsContainerOrAnything"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C00F"
android:clickable="true"
android:focusable="true"
>
</FrameLayout>
</FrameLayout>
The button would show through the FrameLayout.... In this case, literally "out of the blue" because the button has depth and so it emerges over the layout, even though the layout is placed "upon" the button.
The question is:
How do I make the FrameLayout cover the underlying Button without fiddling with its elevation.
How do I make the button flat? Of course I can just set it back to the origins and call it "TextView". But is there a nicer way?
Thanks
Add your button inside FrameLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C00F"
android:clickable="true"
android:focusable="true" />
</FrameLayout>
I want to set the logo of my app to the bottom left hand side of the screen and be in the background. the reason i want to do this is to allow the users to modify the background colors which would not be possible if i simply set the entire activity or layout background to an image to give same impression.
Another way of asking this is how do i set an image to bottom left hand corner and below other controls?
i don't know if i understand correct. but what you ask is pretty simple.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbbbbb"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="bottom|left"
android:layout_margin="10dp"
android:src="#ffff00" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:orientation="vertical">
<!-- Put your views here -->
</LinearLayout>
</FrameLayout>
you can change the frame layout's background as you wish and keep logo on bottom left corner.
Also you can set your LinearLayout (which you can use any layout. it is up to you) background to transparent so you will see background. and any extra view inside the linear layout (your view container) will be on top always.
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="#drawable/your_desired_full_background">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher_logo"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
In my application I want to have a layout like this:
I did it with a Relative Layout holding an ImageView, TableLayout and a Button. The problem is that when I open the keyboard to modify a EditText the keyboard is on top of the EditText, so the user can't see what he is writing. I want the layout to be like this when the keyboard is shown:
The user should be able to scroll up the view to see the whole image while the keyboard is shown, even if he doesn't see the EditText then, because he wants to copy some data of the image into the EditTexts. I tried to do it like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/buttonEditStop"
android:padding="10dip" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/stopImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:clickable="true"
android:contentDescription="#string/entry_img"
android:onClick="ImageClick" />
<TableLayout
android:id="#+id/formLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stopImg"
android:layout_marginRight="10dp" >
...
</TableLayout>
</RelativeLayout>
</ScrollView>
<ImageButton
android:id="#+id/buttonEditStop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:contentDescription="#string/edit_stop"
android:onClick="EditButtonClicked"
android:src="#drawable/ic_menu_edit" />
Using this code my whole layout is screwed. I see the form on top of the image, followed by a ImageButton with the image that should be seen in the imageView.
Anyone knows how I can get a layout like the one I want?
Thanks!
To avoid the EditText to be overlapped I had to use
android:windowSoftInputMode="adjustPan"
in my manifest.
I need to know how to put two overlapped navigation buttons on ImageView. To make clear, I want to previous and next navigation buttons in ImageView.
Use this layout to wrap your image with two buttons above it on the top left corner.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:src="#drawable/ic_launcher"
android:layout_alignTop="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignBottom="true"/>
<Button
android:id="#+id/buttonLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<Button
android:id="#+id/buttonRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/bbuttonLeft"/>
</RelativeLayout>
why using ImageView you can use a Layout and set it's background. and then put the buttons as you wish.
if you insist on using and ImageView
<RelativeLayout
android:layout_height="..."
android:layout_width="...">
<ImageView
android:layout_height="match_parent"
android:layout_width="match_parent"/>
<!-- put the buttons in here as you like -->
</RelativeLayout>
Wrap the ImageView into RelativeLayout and use `android:layout_alignTop="#+id/imageView".