Floating Action Button on RecycleView Overlap - java

I'm trying to create an app with Floating Action Button at top of my RecycleView on Fragment, can someone guide me how can i put my floating action button that will overlap my RecycleView without putting it on MainActivity?
i want to remove this part
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.filing.timelog.TimelogFilingFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_weight="4"
android:layout_height="0dp"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:backgroundTint="#color/borderColor"
android:layout_margin="16dp"
app:tint="#FFFFFF"
app:srcCompat="#drawable/ic_add"/>
</LinearLayout>

I am adding an example code (as same as your code with the expected result) using ConstraintLayout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="vertical">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/floating_action_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never">
</androidx.recyclerview.widget.RecyclerView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_margin="16dp"
android:backgroundTint="#color/borderColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="#drawable/ic_add"
app:tint="#FFFFFF" />
</androidx.constraintlayout.widget.ConstraintLayout>

Try like below:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.filing.timelog.TimelogFilingFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:backgroundTint="#color/borderColor"
android:layout_margin="16dp"
app:tint="#FFFFFF"
app:srcCompat="#drawable/ic_add"/>
</RelativeLayout>
Result:

Try this code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#layout/app_toolbar"
android:layout_weight="0.6"
android:orientation="vertical"
android:stateListAnimator="#null">
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_asset_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:background="#android:color/transparent"
android:backgroundTint="#color/white"
android:src="#drawable/icon_camera"
app:rippleColor="#color/white" />
<android.support.v7.widget.RecyclerView
android:id="#+id/messages"
android:layout_width="match_parent"
android:layout_height="451dp"
android:layout_weight="1"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />

Related

How to scale pink box so that it will fit perfectly in the grid of spreadsheet no matter the screen size of phone? Android Studio

Image
The pink box is a tablelayout and the spreadsheet is a constraint layout. I have tried using margins and constraints but when I run it on different phones, the pink box always ends up outside or will be too small. Code right now:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_centerHorizontal="false"
android:layout_gravity="center_horizontal"
android:background="#drawable/game1"
android:maxWidth="500dp">
<TableLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="44dp"
android:layout_marginLeft="44dp"
android:layout_marginTop="147dp"
android:layout_marginEnd="2dp"
android:layout_marginRight="1dp"
android:layout_marginBottom="51dp"
android:layout_weight="1"
android:foreground="#CBD81B60"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:visibility="visible">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
you can use constraintlayout.widget.Guideline and use layout_constraintGuide_percent like this
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_centerHorizontal="false"
android:layout_gravity="center_horizontal"
android:background="#drawable/game1">
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".2"/>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent=".1"/>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guide_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent=".9"/>
<TableLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:foreground="#CBD81B60"
app:layout_constraintBottom_toBottomOf="#id/guide_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="#id/guide_start"
app:layout_constraintTop_toTopOf="#id/guide_top"
app:layout_constraintVertical_bias="0.0"
tools:visibility="visible">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
you can change layout_constraintGuide_percent as you wish
hope this help

using textIsSelectable in textView

I use android:textIsSelectable="true" for TextView.
To enabled copy/select/paste For TextView it is OK
Issue
When I open this activity, it scrolls to middle automatically, like this Link
Why did this problem happen?
This is my layout code.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res/android" >
<data>
<variable
name="aboutMbti"
type="mbtitest.kiars.me.mbti.model.AboutMbti"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="2dp"
app:cardElevation="5dp" >
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbarSize="1dp"
android:scrollbarThumbVertical="#android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img_splash_mtbi"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="3dp"
android:adjustViewBounds="true"
android:padding="5dp"
android:scaleType="centerCrop"
bind:imageUrl="#{aboutMbti.imageUrl}"/>
<TextView
android:id="#+id/txt_content_about_mtbi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/img_splash_mtbi"
android:layout_margin="5dp"
android:textIsSelectable="true"
android:padding="#dimen/title_padding"
android:text="#{aboutMbti.textContent}"
android:textColor="#color/ques_title"
android:textSize="15sp"
android:textStyle="bold"/>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</layout>
Solution
You can add either android:focusableInTouchMode="true" or android:descendantFocusability="blocksDescendants" to the child layout in NestedScrollView
Try below code in your layout:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
...... >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true" >
...........
Finally, According to https://stackoverflow.com/users/6891563/khemraj comment, I Find
Mey solution ...
Just add android:focusableInTouchMode="true" to ImageView Like this :
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res/android" >
<data>
<variable
name="aboutMbti"
type="mbtitest.kiars.me.mbti.model.AboutMbti"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="2dp"
app:cardElevation="5dp" >
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbarSize="1dp"
android:scrollbarThumbVertical="#android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img_splash_mtbi"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="3dp"
android:adjustViewBounds="true"
android:padding="5dp"
android:focusableInTouchMode="true"
android:scaleType="centerCrop"
bind:imageUrl="#{aboutMbti.imageUrl}"/>
<TextView
android:id="#+id/txt_content_about_mtbi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/img_splash_mtbi"
android:layout_margin="5dp"
android:textIsSelectable="true"
android:padding="#dimen/title_padding"
android:text="#{aboutMbti.textContent}"
android:textColor="#color/ques_title"
android:textSize="15sp"
android:textStyle="bold"/>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</layout>
Tnx Guys

Fragment going over ActionBar in ViewPager

I am using viewpager to show different fragments but in this one of fragment replaces the actionbar. Till now I have found that it is because of edittext which I am using for searching items. When I remove edittext from this it works fine.
The main activity layout is a CoordinatorLayout, containing the typical AppBarLayout and then a ViewPager and it is filling whole screen.
fragment_gst_rates.xml:
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="5dp"
tools:context="com.kamalarora.mygst.FragmentGstRates">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/linearLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/searchBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search items . . ."
android:layout_marginTop="5dp"
android:layout_marginBottom="2dp"
android:drawableRight="#android:drawable/ic_menu_search"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/lightGrey">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Products"
android:textSize="18dp"
android:layout_marginLeft="1dp"
android:padding="5dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GST Rate"
android:layout_marginRight="1dp"
android:textSize="18dp"
android:gravity="right"
android:padding="3dp"/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/listView">
</ListView>
</LinearLayout>
</LinearLayout>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context="com.kamalarora.mygst.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<View
android:id="#+id/appbar_bottom"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/transparent"
android:visibility="invisible" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="104dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomNav"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
app:itemBackground="#color/white"
app:itemIconTint="#color/mediumgrey"
app:itemTextColor="#color/mediumgrey"
app:menu="#menu/menu_bottom" />
<!--<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#android:drawable/ic_dialog_email" /> -->
</android.support.design.widget.CoordinatorLayout>
do you tried with the linear layout at the root there try change with android:layout_height="wrap_content" .

How to design this Grid view xml page?

I want to design xml page this type. I tried many of the code. Every time new problems are come. I need bottom navigation bar is fixed. In grid view ,i want android:numColums=3, android:verticalSpacing and android:horizontalSpacing Same(Look like instagram profile view grid images ).
XMl Code:
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainSettingClass">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="175dp"
android:background="#dadada"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/com_facebook_button_background"/>
<TextView
android:id="#+id/amsc_txt_fbusername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView"
android:layout_marginTop="2dp" />
</LinearLayout>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/grid_test"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:background="#FFFFFF"
android:stretchMode="columnWidth"
android:columnWidth="85dp"
android:numColumns="3"/>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#ffffff"
app:menu="#menu/bottom_navigation_gallery"/>
</FrameLayout>
As per your design you need scrollview for 2 above components and your BottomNavigationView is fix (not movable).
In your code you are not using scrollview first and second i'm not sure why you're using framelayout!
Here's my code which is exactly as per your given design try this if any concern you can ask! :)
Here's my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_gallery">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/rel_titleHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#dadada"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#mipmap/ic_launcher" />
<TextView
android:id="#+id/amsc_txt_fbusername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<GridView
android:id="#+id/grid_test"
android:layout_width="match_parent"
android:layout_height="400dp"
android:columnWidth="85dp"
android:horizontalSpacing="2dp"
android:numColumns="3"/>
</LinearLayout>
</ScrollView>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_alignParentBottom="true" />
</RelativeLayout>

Android layout by layout

How could i achive next one after another layouts position (with height)?
Current code:
<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=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="Новая заметка"/>
</RelativeLayout>
</RelativeLayout>
You can achieve the same layout when you will add "layout_above" property use this code.
<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=".MainActivity">
<RelativeLayout
android:layout_above="#+id/relativeBottom"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="Новая заметка"/>
</RelativeLayout>
</RelativeLayout>
I would suggest this
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/myButton">
</ListView>
<Button
android:id="#+id/myButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22dp"
android:text="New Note"
android:layout_marginBottom="5dp"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Because I don't see the reason to put relative layout insid another relative layout.
In my understanding of what is needed, there's little need for relative layout at all. It can be achieved with just LinearLayout, which is less expensive.
<?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:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="#+id/myButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22dp"
android:text="New Note"
android:layout_marginBottom="5dp"
/>
</LinearLayout>

Categories