Here's a simplified version of the portrait UI I want from my layout:
It's a ListView above another layout.
The complication is that I want the whole bottom layout (in this case 'Button2') to be visible when lots of lines get added to the EditText:
I've been trying to achieve this by nesting a RelativeLayout inside a LinearLayout. Unfortunately, the ListView disappears when I get the effect I want with the EditText, e.g.
I've tried loads of alternatives, but nothing seems to achieve both goals.
Here's my XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/AAA"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<LinearLayout
android:id="#+id/BBB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/AAA"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/list_container"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="#array/list_items"/>
</LinearLayout>
<RelativeLayout
android:id="#+id/input_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button1"
android:layout_above="#+id/bottom_layout"
android:layout_width="100dip"
android:layout_height="50dip"
android:clickable="true"
android:text="Button1" />
<EditText
android:id="#+id/edittext"
android:layout_above="#+id/bottom_layout"
android:layout_toRightOf="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dip"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine"
android:maxLines="8"
android:scrollbars="vertical" />
<!-- Align this with the bottom so when the input text area gets
really big it doesn't push this section off screen -->
<LinearLayout
android:id="#+id/bottom_layout"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="150dip"
android:layout_gravity="bottom"
android:clickable="true"
android:text="Button2" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
If I remove the android:layout_alignParentBottom="true" from the bottom_layout then the ListView contents appears, but then I lose the effect I want with the EditText.
Can anybody help? I need to support OS 2.2+.
Simplifying the layout a bit like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/AAA"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<RelativeLayout
android:id="#+id/BBB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/AAA"
android:orientation="vertical" >
<ListView
android:id="#+id/list"
android:layout_above="#+id/edittext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="#array/list_items"/>
<Button
android:id="#+id/button1"
android:layout_above="#+id/bottom_layout"
android:layout_width="100dip"
android:layout_height="50dip"
android:clickable="true"
android:text="Button1" />
<EditText
android:id="#+id/edittext"
android:layout_above="#+id/bottom_layout"
android:layout_toRightOf="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dip"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine"
android:maxLines="8"
android:scrollbars="vertical" />
<!-- Align this with the bottom so when the input text area gets
really big it doesn't push this section off screen -->
<LinearLayout
android:id="#+id/bottom_layout"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="150dip"
android:layout_gravity="bottom"
android:clickable="true"
android:text="Button2" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
seems to give the result you were describing.
Related
I want to make a layout with fixed header when the keyboard appear.This layout works fine its fixed the header but also show the Title bar. The problem I'm facing is when i hide the Title bar and want to show the layout full screen the header move again when soft keyboard appear.
<?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" >
<!-- Header aligned to top -->
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#FC9"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Fixed Header"
android:textColor="#000"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent" android:clickable="false"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/listView"
android:listSelector="#android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/form"
android:layout_alignParentTop="true" >
</ListView>
<RelativeLayout
android:id="#+id/form"
android:clickable="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:ems="10"
android:inputType="text" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
when I hide the title bar with
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
or
android:theme=”#android:style/Theme.NoTitleBar”
the header moves again.
I also add the scrollview in the layout then the problem I'm facing is the header is fixed but the keyboard appear on the editbox and the list is not scroll.
<?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" >
<!-- Header aligned to top -->
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#FC9"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Fixed Header"
android:textColor="#000"
android:textSize="20sp" />
</RelativeLayout>
<ListView
android:id="#+id/listView"
android:listSelector="#android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/form1"
android:layout_alignParentTop="true" >
</ListView>
<ScrollView
android:id="#+id/login_sv_login_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:background="#android:color/transparent" >
<LinearLayout
android:id="#+id/login_ll_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#android:color/transparent"
android:orientation="vertical" >
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:ems="10"
android:inputType="text" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
I also used this but its not work.
android:windowSoftInputMode="adjustResize|stateHidden"
android:windowSoftInputMode="adjustPan" >
I wanted to make a layout with 3 LinearLayouts. In the 2nd LinearLayout I would have a ListView and the 3rd LinearLayout I would have an EditText and Button at the bottom. This was my attempt:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/view_post"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:background="#color/com_facebook_blue">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/view_status"/>
</LinearLayout>
<LinearLayout
android:id="#+id/view_comments"
android:layout_below="#+id/view_post"
android:layout_width="match_parent"
android:layout_height="250dp">
<ListView
android:id="#+id/lv_comments_feed"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
<LinearLayout
android:layout_below="#+id/view_comments"
android:id="#+id/send_message"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<EditText
android:id="#+id/write_comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="5"
android:gravity="top|left"
android:inputType="textMultiLine"
android:scrollHorizontally="false" />
<Button
android:id="#+id/send_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</RelativeLayout>
Now the design looks great but when I load the app on my phone, I have 2 problems:
I don't want to hardcode the LinearLayout heights. I have looked into layout_weight but I can't seem to have these layout_weights work without running into the 2nd problem below:
When I click the EditText, the EditText is hidden even though I have declared android:windowSoftInputMode="adjustResize|stateHidden" in my activity and I'm not sure why that's happening. Also, the EditText and Button are not directly at the bottom of the screen which is what I would want. Any help is appreciated, thanks!
you don't need to add listview as child of linear layout. and avoid fill_parent & use match_parent. if first linear layout is only for textview then don't use it inside of linearlayout. or only use wrap_content instead of a specific layout_height
Here i made some changes hope it will work
<?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">
<LinearLayout
android:id="#+id/view_post"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#222dc9">
<TextView
android:id="#+id/view_status"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/send_message"
android:layout_below="#id/view_post"
></ListView>
<LinearLayout
android:id="#+id/send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<EditText
android:id="#+id/write_comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="5"
android:gravity="top|left"
android:inputType="textMultiLine"
android:scrollHorizontally="false" />
<Button
android:id="#+id/send_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</RelativeLayout>
and use in Manifest with activity name is
android:windowSoftInputMode="adjustPan"
<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:id="#+id/view_post"
android:layout_width="match_parent"
android:background="#color/material_grey_300"
android:padding="5dp"
android:layout_height="wrap_content">
<TextView
android:id="#+id/view_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/view_comments"
android:layout_above="#+id/send_message"
android:layout_below="#+id/view_post"
android:layout_width="match_parent"
android:background="#color/material_deep_teal_200"
android:padding="10dp"
android:layout_height="match_parent">
<ListView
android:id="#+id/lv_comments_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</RelativeLayout>
<LinearLayout
android:id="#+id/send_message"
android:background="#color/material_blue_grey_800"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<EditText
android:id="#+id/write_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textMultiLine"
android:scrollHorizontally="false" />
<Button
android:id="#+id/send_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:layout_weight="1"
android:text="send" />
</LinearLayout>
</RelativeLayout>
I have this simple piece of code in my app:
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="fill_horizontal"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ProgressBar
android:id="#+id/elapsedTimeBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/elapsedTimeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/time_mockup"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/next"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:onClick="onNextClick"
android:text="#string/next" />
</LinearLayout>
</LinearLayout>
I want to achieve situation where button is on the right side of ProgressBar and ProgressBar fills whole spave left by Button.
I supposed code above will handle this, but in my case ProgressBar is streched and push out from canvas whole LinearLayout with Button . Can i do somehow that button (or layout with button) is a point of reference and "positioner" starts make order from it?
Change the width to "wrap_content" on the progressbar?
read more here:
http://ritald.blogspot.com/2013/05/lesson-6-android-wrapcontent-and.html
I figured it out:
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="fill_horizontal"
android:orientation="horizontal" >
<LinearLayout
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ProgressBar
android:id="#+id/elapsedTimeBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/elapsedTimeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/time_mockup"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/next"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:onClick="onNextClick"
android:text="#string/next" />
</LinearLayout>
</LinearLayout>
It means Layout should be wrapped around button and layout with bar should have
android:layout_weight="1"
I dont know why this mechanism is such not intuitive, but it works.
i have two layouts vertically , first one has edittext and button, second one has two listvies ,
the first one doesn't appear, and i got an exception when running the application
<?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" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/etRestaurantSearchName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Enter name"
android:inputType="text"
android:textSize="15dip" />
<Button
android:id="#+id/bRestaurantSearchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Search" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ListView
android:id="#+id/lvRestaurants"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffffff"
android:fillViewport="true" >
</ListView>
<ListView
android:id="#+id/lvAlphabets"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="#drawable/foods_alphabets_bg"
android:orientation="vertical" >
</ListView>
</LinearLayout>
</RelativeLayout>
i ma sure it is something about hiegh , width or weight,
You have used RelativeLayout as the parent layout for the inner two layouts. Therefore the second inner Linear Layout overlaps the first one , thus first one cant be seen. Make use of linear layout as parent layout
Try this:
Correction :
android:layout_below="#+id/Layout1" for layout two.
and some weight related changes.
<LinearLayout
android:id="#+id/Layout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/etRestaurantSearchName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Enter name"
android:inputType="text"
android:textSize="15dip" />
<Button
android:id="#+id/bRestaurantSearchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Search" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Layout1"
android:orientation="horizontal" >
<ListView
android:id="#+id/lvRestaurants"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/edit_text"
android:fillViewport="true" >
</ListView>
<ListView
android:id="#+id/lvAlphabets"
android:layout_width="40dp"
android:layout_height="match_parent"
android:background="#drawable/btn_bg_pressed"
android:orientation="vertical" >
</ListView>
</LinearLayout>
I'm encountering a problem where my scrollbar is overlapping with an element from my layout. I'd like for the scroll bar to appear after the edit box: . When adding the scroll bar to different parts of the xml file, I received error messages which I understand to mean that the scrollview had to be the root element. As a result, my code looks like this (when I feel like the scroll view should come after the first linear layout and/or edit box):
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/db1_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout style="#style/TitleBar">
<ImageView style="#style/TitleBarLogo"
android:contentDescription="#string/description_logo"
android:src="#drawable/logo" />
<ImageView style="#style/TitleBarSeparator" />
<TextView style="#style/TitleBarText" />
<ImageButton style="#style/TitleBarAction"
android:contentDescription="#string/description_about"
android:src="#drawable/about"
android:onClick="onClickAbout" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:id="#+id/status"
android:layout_height="wrap_content">
<requestFocus></requestFocus>
</EditText>
<Button android:layout_width="wrap_content" android:text="Ok" android:textColor="#color/title_text" android:layout_gravity="center" android:background="#drawable/custom_button" android:layout_height="wrap_content"></Button>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content" android:text="" android:id="#+id/updates" android:textSize="14dp" android:layout_height="wrap_content"></TextView>
</LinearLayout>
<TextView android:text="" android:id="#+id/test" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>
</LinearLayout>
</ScrollView>
This may work for you: android:scrollbarStyle="outsideOverlay", set this inside the <ScrollView>
Give your LinearLayout or your ScrollView some padding.
I figured this out after chatting with the commonsguy (+1). I misunderstood the android error I received about scroll views and root elements. From my understanding, a scroll view can only have one child. My initial thought was that the scroll view needed to be surround the root element (oops). Here's the fix:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/db1_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout style="#style/TitleBar">
<ImageView style="#style/TitleBarLogo"
android:contentDescription="#string/description_logo"
android:src="#drawable/logo" />
<ImageView style="#style/TitleBarSeparator" />
<TextView style="#style/TitleBarText" />
<ImageButton style="#style/TitleBarAction"
android:contentDescription="#string/description_about"
android:src="#drawable/about"
android:onClick="onClickAbout" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:id="#+id/status"
android:layout_height="wrap_content">
<requestFocus></requestFocus>
</EditText>
<Button
android:layout_width="wrap_content"
android:text="Go"
android:textColor="#color/title_text"
android:layout_gravity="center"
android:id="#+id/communitysubmit"
android:background="#drawable/custom_button"
android:layout_height="wrap_content">
</Button>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/linearLayoutcommunity"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:text=""
android:id="#+id/updates"
android:textSize="14dp"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</ScrollView>
<TextView
android:text=""
android:id="#+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
Late but I've tried this solution.
Put a Linear layout inside scroll view and then give margin to Linear layout. After that add put your content inside linear layout. Hopefully this will solve issue.
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginEnd="#dimen/_10sdp"
>
//your content here
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>