Make RecyclerView Scroll inside Fixed height - java

I want to Scroll ReyclerView inside a Fixed height/region.
Sample XML to demonstrate the use case
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ele_parent_ll"
android:layout_width="match_parent"
android:orientation="vertical"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="#+id/election_parent_sv"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/sample_id"
android:background="#color/white"
android:fitsSystemWindows="true">
<ImageView
android:contentDescription="#string/btn_youtube"
android:layout_width="match_parent"
android:layout_height="115dp"
android:id="#+id/election_banner"
android:background="#drawable/some_drawable"
android:adjustViewBounds="true"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/mid_parent"
android:layout_marginLeft="#dimen/view_margin_10"
android:layout_marginRight="#dimen/view_margin_10"
android:layout_marginTop="#dimen/view_margin_10"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/shaded_purple_new_local"
android:text="Layout heading"
android:textColor="#color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Choose one"
android:textColor="#color/icon_yellow"
android:textSize="13sp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/candidate_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/view_margin_10"
android:layout_marginLeft="#dimen/view_margin_10"
android:layout_weight=".5"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--Sample Layout to make the screen scrollable for the example-->
<RelativeLayout
android:id="#+id/samp_RL"
android:layout_width="match_parent"
android:layout_height="200dp">
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
In this scenario, the RecyclerView is taking it's required space and list is pretty much long so the total length of the scrollable area has gone long so probability of seeing elements below RCV has decreased.
To solve this I want to scroll RecyclerView inside a fixed area so that If the user is not interested in that he can easily look up to the other Elements present below the RecyclerView
When user scrolls within the region of RCV the RCV should scroll.
When the user scrolls outside the RCV the whole Layout should scroll
Image made at draw.io
What I have tried:
Making the height of RecyclerView constant: It is Jammed and is not scrolling at all.
Making Recyclerview Fixed Height and Scrollable : It's also the same. It is jammed and is not scrolling at all.
Scrollable NestedScrollViews inside RecyclerView: Tried this but could not establish a connection to my current situation.
Please tell what I am missing here.

you do not need to do anything. by default it works like this only !
Try the below code -
recyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
recyclerView.setHasFixedSize(false);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
mAdapter = new MyAdapterClass(getContext(), lst);
recyclerView.setAdapter(mAdapter);
XML
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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="com.example.iosdteachingapp.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="100sp"
android:text="hello"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="200sp"
android:layout_height="300sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end"
android:padding="20sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end"
android:padding="20sp"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end"
android:padding="20sp"/> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end"
android:padding="20sp"/>
</LinearLayout>
</ScrollView>

Add android:nestedScrollingEnabled="false" to your RecyclerView.

Set Recycler view height dynamically thr java using param.
You can even set the height to show only particular no of elements by setting height = size of each element of recycler view * no of elements in the list.
Try this :
ViewGroup.LayoutParams
params=recyclerview.getLayoutParams();
params.height=100;
recyclerview.setLayoutParams(params);

Related

Not able to properly nest GridView inside Cardview

I use a RecyclerView , which renders CardView . This CardView has 2 TextViews and one GridView , The GridView renders CardView (lets call it inside_card )as its child. Now i am unable to change height of this inside_card . Given below is what i want to achieve(Image A) and what i am getting (Image B).
Given Below are my Layouts.
activity_main.xml contains RecylerView
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat 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"
tools:context=".Activities.MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</androidx.appcompat.widget.LinearLayoutCompat>
activity_card.xml Contains Layout to be rendered inside RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardBackgroundColor="#AAA"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:layout_margin="8dp"
android:requiresFadingEdge="vertical">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/proffName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ProfessorName"
android:textAlignment="center"
android:gravity="center_horizontal">
</TextView>
<TextView
android:id="#+id/subjectCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SemesterName"
android:textAlignment="center"
android:gravity="center_horizontal">
</TextView>
<GridView
android:layout_gravity="center"
android:id="#+id/unitsGrid"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="1"
android:layout_margin="6dp"
android:horizontalSpacing="2dp"
android:numColumns="2"></GridView>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.appcompat.widget.LinearLayoutCompat>
inside_card.xml contains layout to be rendered inside GridView
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/inside_card"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_margin="8dp"
app:cardCornerRadius="6dp"
app:cardElevation="6dp"
app:cardBackgroundColor="#eeeeee"
>
<TextView
android:textAlignment="center"
android:layout_gravity="center"
android:id="#+id/unitName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="1dp"
android:textColor="#color/cardview_dark_background"
android:textSize="18dp" />
</androidx.cardview.widget.CardView> ```
Change in inside_card.xml
-> Increase the height of card view from 45dp to 120dp, tweak as per requirement
-> Set card elevation 0dp, as in the design A, there is no card elevation.
-> Even I will suggest, don't take card view for this, Just take simple LienarLayout and set a drawable shape with stroke for this. Because Setting border on card view is a little tedious task.
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/inside_card"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_margin="8dp"
app:cardCornerRadius="6dp"
app:cardElevation="0dp"
app:cardBackgroundColor="#eeeeee"
>
<TextView
android:textAlignment="center"
android:layout_gravity="center"
android:id="#+id/unitName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="1dp"
android:textColor="#color/cardview_dark_background"
android:textSize="18dp" />
</androidx.cardview.widget.CardView> `
In your GridView, set vertical spacing too
<GridView
android:layout_gravity="center"
android:id="#+id/unitsGrid"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="1"
android:layout_margin="6dp"
android:horizontalSpacing="15dp"
android:verticalSpacing="15dp"
android:numColumns="2"></GridView>

Responsive View in Android Studio

friends i am working on Android Studio to develop an app, the app will be used on Tablets and also other android phones. But i am getting some problems while designing the View (Template). Please help me to sort out this problem.
I am using ConstraintLayout as the mainLayout, and inside it i am using linearlayout with vertical orientation. You can check the code and output
If i use the listView highet as 0dp then it will show nothing
<?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:id="#+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/my_images_gallary"
android:textSize="36sp"
android:textStyle="bold" />
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="0dp">
</ListView>
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:text="Button" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
[Output for the height is 0dp][1]
and if i use the ListView Height as match_parent so the bottom button will not appear.
<?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:id="#+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/my_images_gallary"
android:textSize="36sp"
android:textStyle="bold" />
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:text="Button" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Output for the height is match_parent
Actually i want the listView should show all with scrolling and and the button should be seen all time while the listview is being scroll or not.
Expected Output which i am failed to get
Idea 1:
give fixed height to button and textview. Then use 0dp height to listview
Idea 2:
Use weight_sum to linear layout and give layout_weight to button,textview and listview as you expect.

how to put listview inside a horizontalscrollview so that list can scroll hoizontally?

i am creating an application where requirement is like i have list which scroll vertically and inside that list each item is having one list which must scroll horizontally. So i have to set that list inside horizontal scroll view. i have created a custom adpater for that data is showing on the list everything is working fine but only one problem the list is scrolling vertically because i was unable to set that list horizontal. Please help i have searched lots of answers but it is not working.
<LinearLayout 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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<android.support.v7.widget.CardView
android:id="#+id/card_view_applicant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:background="#fff"
app:cardCornerRadius="8dp"
app:cardElevation="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/tv_table_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="T1"
android:textAlignment="center"
android:textColor=" #00008B"
android:textSize="25sp"
android:textStyle="bold" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#000000" />
</LinearLayout>
<HorizontalScrollView
android:id="#+id/hsv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:measureAllChildren="false"
android:scrollbars="none">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_marginLeft="50dp"
android:layout_height="match_parent">
<ListView
android:id="#+id/lv_timing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</HorizontalScrollView>
</android.support.v7.widget.CardView>
</RelativeLayout>
</LinearLayout>
i have tried to do something like this this is but it is not working,and i don't want to use any recyclerview my requirement is just simple i just want to show some that that's why.
You have to use RecyclerView for Horizontal scrollong like:
LinearLayoutManager layoutManager= new
LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);
Use android:layout_weight="1" inside ListView. Make LinearLayout the parent layout of ListView instead of RelativeLayout and check it's work or not. I think it should be work.
<LinearLayout
..........>
<ListView
........
android:layout_weight="1"/>
</LinearLayout>

Android - what kind of view/xml I've to study

Problem I want view-layout like the following photo, on top I want image view, in the middle a text view and bottom list of items. All this I want to be scrollable (black arrow in the picture). in this way, the user for first see image-text-and part of list items, if scroll down, see the list of item.
For the bottom I thought to use listView, but in this way I think I'll have 2 scrollable view (???) and then I want to make the list in 2 columns, and I don't know if it is possible with ListView
Question
I didn't write code, because I want to know what kind of view or somethings else I've to study.
I sketchy something like this, but the result is really horrible
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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">
<RelativeLayout
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
app:srcCompat="#drawable/nope"
android:id="#+id/imageView4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<View
android:id="#+id/centerShim5"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_centerInParent="true"
android:visibility="invisible" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/list"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/textView2"
android:textColor="#color/ame_default_cluster_circle_color_medium"
android:textSize="26dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</ScrollView>
I can't use listview in Scrollview, and inspired by the matryoshka I found the solution.
I define xml1 file in which I have only ScrollView and LinearLayout inside
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:id="#+id/linear">
</LinearLayout>
</ScrollView>
after, for each kind of items that I want to add inside, I define another xml2 and after I add element:
<?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"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/ame_default_cluster_text_color">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="5"
android:textSize="32sp"
android:textColor="#color/ame_default_cluster_circle_shadow_color"
android:id="#+id/text1"
android:textAlignment="center" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#drawable/nope"
android:id="#+id/photo" />
<TextView
android:text=" "
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:id="#+id/descrtiption"
android:textColor="#color/ame_default_cluster_circle_shadow_color"
android:layout_margin="10sp" />
</LinearLayout>
with code:
layoutInflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View item_view=layoutInflater.inflate(R.layout.xml1,container,false);
LinearLayout linearLayout=(LinearLayout)item_view.findViewById(R.id.linear);
LayoutInflater inflater= LayoutInflater.from(ctx);
View view1 = inflater.inflate(R.layout.xml2, linearLayout, false);
TextView text1=(TextView)view1.findViewById(R.id.text1);
text1.setText();
ImageView imageview=(ImageView)view1.findViewById(R.id.photo);
and obviously I can define XML for element to add like listview and add it with normal foreach ,Hope this will help someone.

RecyclerView takes up all screenspace

So I'm having some trouble with a RecyclerView in a layout file
Here it is:
<android.support.v7.widget.RecyclerView
android:id="#+id/chat_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="#dimen/abc_action_bar_default_padding_material"
android:paddingLeft="#dimen/abc_action_bar_default_padding_material"
/>
<LinearLayout
android:layout_below="#id/chat_listview"
android:layout_width="match_parent"
android:layout_height="#dimen/bottom_bar_height"
android:orientation="horizontal"
>
<EditText
android:id="#+id/chat_input_edittext"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:inputType="textAutoCorrect"
/>
<Button
android:id="#+id/chat_send_button"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#drawable/ic_action_send_now"
/>
</LinearLayout>
The RecyclerView is visible and scrollable but the LinearLayout and the Views inside are not visible... I tried quite a few things but nothing has worked so far.
Can any of you please point me into the right direction?
Many thanks in advance!
When RecyclerView is drawn, it calculates all the remaining size on screen to itself before drawing the next elements and don't recalculate after the other elements are drawn, leaving them outside the screen.
The trick is to draw all other elements first, and leave RecyclerView for last. FrameLayout does not work anymore so use a relative layout and put the RecyclerView last on the XML layout file.
Example to add a bar with buttons below the RecyclerView:
<?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="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".MainActivity"
>
<LinearLayout
android:id="#+id/pagination_btns"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"> //HERE YOU ALIGN THIS ELEMENT TO THE BOTTOM OF THE PARENT
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/previous_btn_label"/>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/next_btn_label"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/items_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_above="#id/pagination_btns"/> //HERE YOU ALIGN THE RECYCLERVIEW ABOVE THE PAGINATION BAR
</RelativeLayout>
Change the root view to a FrameLayout. Set the gravity of the LinearLayout to bottom
<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.support.v7.widget.RecyclerView
android:id="#+id/chat_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="#dimen/abc_action_bar_default_padding_material"
android:paddingLeft="#dimen/abc_action_bar_default_padding_material"
/>
<LinearLayout
android:layout_below="#id/chat_listview"
android:layout_width="match_parent"
android:layout_height="#dimen/bottom_bar_height"
android:layout_gravity="bottom"
android:orientation="horizontal">
<EditText
android:id="#+id/chat_input_edittext"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:inputType="textAutoCorrect"/>
<Button
android:id="#+id/chat_send_button"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="#drawable/ic_action_send_now"/>
</LinearLayout>
</FrameLayout>
Alternatively, you can wrap the linear layout in a FrameLayout
and set it to align_parentBottom = true if it is a relative layout or a linear layout at your root and you have other things in your view.

Categories