What I want is that my framelayout is positioned all over the screen untill it reaches my button that stands on the bottom of the screen.
<RelativeLayout 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"
tools:context="com.test.MainActivity">
<FrameLayout
android:id="#+id/container"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</FrameLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:text="Compose"/>
</RelativeLayout>
The only problem is that I load a fragment in the framelayout and that contains a listview. Now when the listview gets to big it pushes my button out of the screen.
Anyone an idea?
Try this:
<RelativeLayout
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"
tools:context="com.test.MainActivity">
<FrameLayout
android:id="#+id/container"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_above="#+id/bottomButton">
</FrameLayout>
<Button
android:id="#+id/bottomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:text="Compose"/>
</RelativeLayout>
Related
I have added a floating action button with recyclerview which is also scrolling along with the recyclerview my problem is that I have a bottom navigation in main activity so I'm trying to put my floating action button above bottom navigation which is in the main layout when my fragment is called but instead my fab is shown at the end of recyclerview and it is also scrolling along with the recyclerview how can I make it not scroll when the fragment is called in MainActivity.
Please any help would be appreciated
My XML
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout 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:orientation="vertical"
tools:context="com.ct.listrtrial.fragments.FeedFragment">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Feed"
android:paddingTop="10dp"
android:paddingLeft="15dp"
android:textSize="35sp"
android:textColor="#color/White"
android:layout_weight="1"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/feed_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:paddingTop="15dp">
</android.support.v7.widget.RecyclerView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="#drawable/ic_search_black_24dp"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Use RelativeLayout as Root layout
And Use android:layout_alignParentBottom="true" and
android:layout_alignParentRight="true" to attach your FloatingActionButton at bottom of screen
SAMPLE CODE
<?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:orientation="horizontal">
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout 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:orientation="vertical"
tools:context="com.ct.listrtrial.fragments.FeedFragment">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:text="Feed"
android:textColor="#color/White"
android:textSize="35sp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/feed_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:paddingTop="15dp">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="5dp"
android:src="#drawable/ic_search_black_24dp" />
</RelativeLayout>
You Should put floating action button outside of nested scrollview..
Why is the VideoView taking up so much space?
My RecyclerView contains of a header part (for the VideoView) and an item part.
It tried to fix it with match_parent and wrap_content but the result was still the same.
Right below the video (in the gray area) should be the ListItems. At least one you can see at the bottom of the screen.
main.xml
<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"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="80dp"
android:scrollbars="vertical"/>
</FrameLayout>
item.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textViewItem"
android:textSize="22sp"
android:layout_marginRight="12dp"
android:layout_marginLeft="57dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
header.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<VideoView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:id="#+id/videoViewHeader"/>
</RelativeLayout>
Change RelativeLayout tag android:layout_height="match_parent" of item.xml and header.xml to android:layout_height="wrap_content"
The following should show a scrollview that takes up the entire screen except for a small portion large enough for a button at the bottom. When I run this the button/layout does not show up at all. Only the scrollview which takes up the entire screen with other views I have within the scrollview. Thoughts?
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.th3ramr0d.armybodyfatcalculator.MainActivity"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
/>
</LinearLayout>
</LinearLayout
This will do the job for you
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context="com.th3ramr0d.armybodyfatcalculator.MainActivity"
xmlns:tools="http://schemas.android.com/tools"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="#+id/myButton">
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"
android:layout_alignParentBottom="true"
android:id="#+id/myButton" />
</RelativeLayout>
I have following 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/viewGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/textLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<ListView
android:id="#+id/testList"
android:layout_width="match_parent"
android:layout_height="75dp"
android:visibility="gone" />
</LinearLayout>
<RelativeLayout
android:id="#+id/anotherLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="#+id/messageText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
So when the textLayout is clicked, it will determine the visibility of testList.
When the visibility becomes VISIBLE, it works well. However, when the visibility becomes GONE, the anotherLayout goes back to original position before the animation of viewGroup ends, so it overlaps the testList.
How can I prevent this?
This is an Android question.
How do I add a button to a frame layout, in the same location as my picture?
I am trying to add a button on top of a frame layout (which has a background image and no title bar) like so:
This is the entire code of my layout so far. What code do I add to put a button like in the picture?
activity_home_page.xml:
<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:gravity="center"
tools:context=".HomePage">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/my_background_image"
android:scaleType="fitXY">
</ImageView>
</FrameLayout>
How do I add a button to a frame layout, in the same location as my picture?
I have tried & come up with a solution.
<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:gravity="center"
tools:context=".HomePage">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/mod_minecraft"
android:scaleType="fitXY">
</ImageView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_weight="1">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button" />
</LinearLayout>
</LinearLayout>
</FrameLayout>