Showing posts with label android-xml. Show all posts
Showing posts with label android-xml. Show all posts

Thursday, February 8, 2018

Some layouts don't draw when the keyboard goes down

Leave a Comment

I'm working an app that draws objects on SurfaceView under some parameters, defined by the user. I created the layout for the app, which involves an header, footer, input (where user enters parameters to draw) and a custom SurfaceView.

Here's the layout that simplified:

<android.support.constraint.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">      <!-- Custom SurfaceView Layout -->      <org.firengine.myapp.CustomPreview         android:id="@+id/container_content"         android:layout_width="0dp"         android:layout_height="0dp"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_toStartOf="parent"         app:layout_constraintTop_toTopOf="parent" />      <!-- Header Layout: This is basically a Toolbar, with having a top padding of status bar height (see Note). -->      <FrameLayout         android:id="@+id/container_header"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:background="@color/colorTint"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_toStartOf="parent"         app:layout_constraintTop_toTopOf="parent">...</FrameLayout>      <!-- Footer Layout - This is just a container, with having a bottom padding of navigation bar height (see Note). -->      <FrameLayout         android:id="@+id/container_footer"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:background="@color/colorTint"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_toStartOf="parent">...</FrameLayout>      <!-- Input Layout - This is a empty container that shows views dynamically. -->      <LinearLayout         android:id="@+id/container_input"         android:layout_width="0dp"         android:layout_height="0dp"         android:gravity="bottom|center_horizontal"         android:orientation="vertical"         app:layout_constraintBottom_toTopOf="@+id/container_footer"         app:layout_constraintEnd_toEndOf="parent"         app:layout_constraintStart_toStartOf="parent"         app:layout_constraintTop_toBottomOf="@+id/container_header" />  </android.support.constraint.ConstraintLayout> 

The input layout generate dynamic views, based on parameters.

Suppose I create a EditText inside input layout, so that the keyboard appears if you interact with that.

This is before the keyboard shows up.

Before Keyboard Shows Up.

This is when the keyboard is showing. Notice that the app layout is panned and the header layout got invisible.

Keyboard Is Showing.

The problem occurs when the keyboard goes down. The header layout, which is invisible earlier, stays invisible all the time (until the user interacts with the app).

After Keyboard Shows Up.

I turned on GPU overdraw to check the problem (also setting SurfaceView background color to white), and here is the result.

Before:

Before with GPU overdraw.

After:

After with GPU overdraw.

Also, here's my custom SurfaceView class (I think that the custom SurfaceView is blocking the UI thread to draw the layouts that disappeared).

public class CustomPreview extends SurfaceView implements SurfaceHolder.Callback {      private final Handler handler = new Handler();     private final Runnable runnable = new Runnable() {         @Override         public void run() {             draw();         }     };      private Renderer renderer;      private boolean visible;     private boolean canLoadData;      private HashMap<String, String> data;      public CustomPreview(Context context, AttributeSet attrs) {         super(context, attrs);         getHolder().addCallback(this);         getHolder().setFormat(PixelFormat.RGBA_8888);         visible = false;         canLoadData = false;         renderer= new Renderer(context);         data = new HashMap<>();     }      @Override     public void surfaceCreated(SurfaceHolder holder) {         visible = true;         refreshHandler(0);     }      @Override     public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {         renderer.updateDimensions(width, height);         canLoadData = true;         renderer.updateData(data);         refreshHandler(0);     }      @Override     public void surfaceDestroyed(SurfaceHolder holder) {         renderer.clearData();         visible = false;         canLoadData = false;         refreshHandler(0);     }      public void setVisibility(boolean visible) {         this.visible = visible;         refreshHandler(0);     }      private void draw() {         Canvas canvas = null;         try {             canvas = getHolder().lockCanvas();             if (canvas != null) {                 renderer.draw(canvas);             }         } finally {             if (canvas != null) {                 getHolder().unlockCanvasAndPost(canvas);             }         }         refreshHandler(60000);     }      public void saveData(String key, String value) {         data.put(key, value);         if (canLoadData) {             renderer.updateData(data);         }         refreshHandler(0);     }      private void refreshHandler(long delay) {         handler.removeCallbacks(runnable);         if (visible) {             if (delay > 0) {                 handler.postDelayed(runnable, delay);             } else {                 handler.post(runnable);             }         }     }      public String loadData(String key) {         return data.get(key);     } 

Am I doing something wrong? If so, can someone explain what it is?

I'm glad if someone helps me out. Thank you.

Note: Heres some extra information about the layout.

  1. Footer layout was originally had a AdView, which is not included in the layout.
  2. SYSTEM_UI_FLAG_HIDE_NAVIGATION and SYSTEM_UI_FLAG_FULLSCREEN flags was added to the activity and because of that, paddings were set in respective layouts to avoid overlapping.
  3. And, header layout has 2 Toolbar views, which one of them are seen in the images above.

1 Answers

Answers 1

Try following in the Manifest

android:windowSoftInputMode="adjustNothing"

<activity      android:name=".app.main.MainActivity"     android:windowSoftInputMode="adjustNothing">         <intent-filter>             <action android:name="android.intent.action.MAIN" />             <category android:name="android.intent.category.LAUNCHER" />         </intent-filter> </activity> 
Read More

Wednesday, May 10, 2017

Extra space using coordinator layout while scrolling

Leave a Comment

In my app Am using CoordinatorLayout.When am trying to scroll lot of extra space is available.And i have changed that by using setting coordinator layout height.But when am trying to change the tab which is showing extra space.When am clicking in the form tab1,tab2,tab3 there is no issue.But when am trying to do with tab3,tab2,tab1 in tab3 and tab2 showing lot of extra space.

1) In my main activity am using Observable scrollview.      <?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"     android:id="@+id/kudix_cordinator"     android:layout_width="match_parent"     android:layout_height="wrap_content">      <android.support.design.widget.AppBarLayout         android:id="@+id/appbar"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="?attr/colorPrimary"         android:fitsSystemWindows="false"         android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"         app:layout_collapseMode="pin">          <android.support.design.widget.CollapsingToolbarLayout             android:id="@+id/htab_collapse_toolbar"             android:layout_width="match_parent"             android:layout_height="250dp"             android:layout_marginBottom="0dp"             app:contentScrim="?attr/colorPrimary"             app:titleEnabled="false">              <ImageView                  android:layout_width="match_parent"                 android:layout_height="@dimen/parallax_image_height"                 android:background="@drawable/ic_launcher"                 android:fitsSystemWindows="true"                 android:scaleType="centerCrop"                 app:layout_collapseMode="parallax" />              <android.support.design.widget.TabLayout                 android:id="@+id/tabs"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_gravity="bottom"                 app:tabIndicatorColor="@android:color/white"                 app:tabSelectedTextColor="@android:color/white"                 app:tabTextColor="@color/white" />          </android.support.design.widget.CollapsingToolbarLayout>      </android.support.design.widget.AppBarLayout>       <android.support.v4.view.ViewPager         android:id="@+id/kudix_club_viewpager"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_marginBottom="10dp"         android:layout_marginLeft="15dp"         android:layout_marginRight="15dp"         app:layout_behavior="@string/appbar_scrolling_view_behavior"         /> </android.support.design.widget.CoordinatorLayout> 

Each tab fragment contain different types of UI.

1 Answers

Answers 1

Actually it was taking my list view height from the other layout.The progress dialog was not dismissing so the API keep on calling .And in that API i was setting coordinator layout height.For each tab am setting coordinator layout height.

Read More

Saturday, February 11, 2017

TextView getting cut in some resolutions

Leave a Comment

I have a RecyclerView which consists of CardViews that have a TextView and an ImageView, among some other layouts.
The problem is, in some screen resolutions the TextView gets cut off or shoved to the next line, which I don't want.
In other resolutions, the TextView has plenty of room.

Small Resolutions:
Small

High Resolutions:
enter image description here

How do I organize the layout so that there is enough room for the TextView, and the ImageView will be sized accordingly?

This is my xml for the RecyclerView items:

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cardview="http://schemas.android.com/apk/res-auto" android:id="@+id/zmanCard" android:layout_width="match_parent" android:layout_height="50dp" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" cardview:cardUseCompatPadding="false" cardview:cardPreventCornerOverlap="false" cardview:cardCornerRadius="4dp" cardview:cardElevation="2dp"> <LinearLayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="?attr/colorPrimary"     android:orientation="vertical">     <LinearLayout         android:layout_width="match_parent"         android:layout_height="20dp"         android:layout_gravity="top"         android:gravity="center"         android:orientation="vertical"         android:background="?attr/colorPrimaryDark">         <TextView             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:id="@+id/zmanCardTitle"             android:textColor="#ffffff"             android:gravity="center"             android:textSize="13sp" />     </LinearLayout>     <LinearLayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="horizontal">         <ImageView             android:layout_width="24dp"             android:layout_height="wrap_content"             android:layout_marginTop="2dp"             android:layout_marginLeft="2dp"             android:layout_marginRight="4dp"             android:alpha="0.8"             android:id="@+id/zmanCardImage" />         <FrameLayout             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginTop="7dp"             android:layout_marginLeft="0dp"             android:layout_marginRight="4dp">             <TextView                 android:text="5:40"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginLeft="2dp"                 android:id="@+id/zmanCardTime"                 android:textColor="#ffffff"                 android:textSize="18sp" />             <ProgressBar                 android:id="@+id/zmanProgressBar"                 android:layout_width="24dp"                 android:layout_height="24dp"                 android:layout_gravity="top|left"                 style="@style/Base.Widget.AppCompat.ProgressBar" />         </FrameLayout>     </LinearLayout> </LinearLayout> 

9 Answers

Answers 1

Try this. Works 100%.

AutoResizeTextView or sdp unit can help you.

SDP - a scalable size unit

An android SDK that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens.

for text views please refer to ssp which is based on the sp size unit for texts.

https://github.com/intuit/sdp

Auto Scale TextView Text to Fit within Bounds

Answers 2

I can suggest two step solution one for your text size so with wrap_content attribute it gets fit to text and I suggest using a qualifier to provide several alternative layouts to target different screen configurations. You do so by using configuration qualifiers, which allows the run-time to automatically select the appropriate resource based on the current device’s configuration (such as a different layout design for different screen sizes). Supporting Different Screen Sizes

I think you need to check this Google IO Pdf for Design. In that pdf go to Page No:77 in which you will find how there suggesting for using dimens.xml for different devices of android for example see below structure:

res/values/dimens.xml

res/values-small/dimens.xml

res/values-normal/dimens.xml

res/values-large/dimens.xml

res/values-xlarge/dimens.xml

for Example you have used below dimens.xml in values.

<?xml version="1.0" encoding="utf-8"?> <resources>    <dimen name="text_size">18sp</dimen> </resources> 

In other values folder you need to change values for your text size.

for example:

<resources>     <!-- Default screen margins, per the Android Design guidelines. -->     <dimen name="activity_horizontal_margin">16dp</dimen>     <dimen name="activity_vertical_margin">16dp</dimen>     <dimen name="font_size_small">10sp</dimen>     <dimen name="font_size_medium">20sp</dimen>     <dimen name="font_size_large">30sp</dimen> </resources> 

Answers 3

enter image description here

A TextView that automatically resizes text to fit perfectly within its bounds.

Usage:

dependencies {     compile 'me.grantland:autofittextview:0.2.+' } 

Enable any View extending TextView in code:

AutofitHelper.create(textView); 

Enable any View extending TextView in XML:

<me.grantland.widget.AutofitLayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     >     <Button         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:singleLine="true"         /> </me.grantland.widget.AutofitLayout> 

Use the built in Widget in code or XML:

<RootElement     xmlns:autofit="http://schemas.android.com/apk/res-auto"     ... <me.grantland.widget.AutofitTextView     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:singleLine="true"     android:maxLines="2"     android:textSize="40sp"     autofit:minTextSize="16sp"     /> 

Reference Link : https://github.com/grantland/android-autofittextview

Answers 4

If you want scalable screens, You shouldn't use fixed height or width as much as possible. In your case, you should place your components proportionately with layout_weight.

For more details;

What does android:layout_weight mean?

Answers 5

For more simple way create your layout using relative layout with some proper technic sure it will resolve. if still haveing issue ask me for .xml file

Answers 6

You should use padding so that textview always has some fixed padding and it never gets cut. In your code make following changes

  <TextView             android:text="5:40"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginLeft="2dp"             android:id="@+id/zmanCardTime"             android:textColor="#ffffff"             android:padding:"3dp"             android:textSize="18sp" /> 

Answers 7

try giving weight to the textview layout and imageview layout give weight 1 to both layouts

Answers 8

Use AutoScaleTextView

The AutoScaleTextView takes the android:textSize value and uses it as the preferred text size. You can also set the minimum text size. The default for the minimum text size is 10dp. The AutoScaleTextView now tries to take the maximum value between the preferred and minimum size that fits into the Views width (with regarding the padding).

Please find full AutoScaleTextView class and its implementations in below LINK

http://ankri.de/autoscale-textview/

Answers 9

My experience in android I always use dp instead of sp, so u fix the dp value for all your textviews and will fit anyscreen.

Let me know if any issue.

Best Regds

Read More

Tuesday, March 8, 2016

Android XML cutting off bottom half of layout

Leave a Comment

I have a problem with my XML layout, something that I thought wouldn't give me many problems. I have a layout below in a scroll view, but the bottom of the layout is being cut off, I can't see anything past the second list view. From looking around, I can't seem to see anything wrong with the xml itself and I can't see what I am doing wrong.

I have tried the suggestion to the problem, that is adding a weight to each of the different elements but this still hasnt solved the problem.

I have also added the main activity in which the fragment is placed incase that might help solve the problem

Fragment 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" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinatorLayout"> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:fillViewport="true"     android:scrollbars="vertical">     <LinearLayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:orientation="vertical">         <android.support.design.widget.TextInputLayout             android:id="@+id/text_input_layout"             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="1">              <EditText                 android:id="@+id/editText"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:hint="Recipe Title"/>         </android.support.design.widget.TextInputLayout>          <TextView             android:id="@+id/ingredientsHeading"             android:layout_below="@+id/text_input_layout"             android:layout_width="fill_parent"             android:layout_height="0dp"             android:text="Ingredients"             android:textStyle="bold|italic"             android:layout_weight="1" />         <ListView             android:id="@+id/ingredientsList"             android:layout_below="@+id/ingredientsHeading"             android:layout_above="@+id/directionsHeading"             android:layout_width="wrap_content"             android:layout_height="195dp"             android:layout_weight="1"></ListView>          <Button style="@style/Button"             android:layout_width="wrap_content"             android:layout_height="0dp"             android:text="Add Ingredient"             android:id="@+id/addIngredient"             android:layout_below="@+id/ingredientsList"             android:enabled="true"             android:layout_gravity="center_horizontal"             android:layout_weight="1" />          <TextView             android:id="@+id/directionsHeading"             android:layout_below="@+id/addIngredient"             android:layout_width="fill_parent"             android:layout_height="0dp"             android:text="Directions"             android:textStyle="bold|italic"             android:layout_weight="1" />         <ListView             android:id="@+id/directionsList"             android:layout_below="@+id/directionsHeading"             android:layout_width="wrap_content"             android:layout_height="195dp"             android:layout_weight="1"></ListView>          <Button style="@style/Button"             android:layout_width="wrap_content"             android:layout_height="0dp"             android:text="Add Direction"             android:id="@+id/addDirection"             android:layout_below="@+id/ingredientsList"             android:enabled="true"             android:layout_gravity="center_horizontal"             android:layout_weight="1" />      </LinearLayout>  </ScrollView>   <android.support.design.widget.FloatingActionButton     android:id="@+id/filterButton"     app:backgroundTint="@color/floatingButton"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="bottom|right"     android:clickable="true"     android:src="@drawable/ic_filter"     android:layout_alignParentBottom="true"     android:layout_alignParentEnd="true"     android:layout_marginBottom="63dp"     android:layout_marginRight="16dp" />   </android.support.design.widget.CoordinatorLayout> 

Main XML

<android.support.v4.widget.DrawerLayout 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/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- The main content view -->  <android.support.design.widget.CoordinatorLayout     android:layout_width="match_parent"     android:layout_height="match_parent"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/drawer_layout2">      <android.support.design.widget.AppBarLayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">          <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/ThemeOverlay.AppCompat.Light" />          <android.support.design.widget.TabLayout             android:id="@+id/tabs"             android:layout_width="match_parent"             android:layout_height="wrap_content"             app:tabMode="fixed"             app:tabGravity="fill"/>     </android.support.design.widget.AppBarLayout>      <android.support.v4.view.ViewPager         android:id="@+id/viewpager"         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_behavior="@string/appbar_scrolling_view_behavior" />      <FrameLayout         android:id="@+id/container_body"         android:layout_width="fill_parent"         android:layout_height="0dp"         android:layout_weight="1" />  </android.support.design.widget.CoordinatorLayout>   <fragment     android:id="@+id/fragment_navigation_drawer"     android:name="com.example.rory.pocketchef.Fragments.FragmentDrawer"     android:layout_width="@dimen/nav_drawer_width"     android:layout_height="match_parent"     android:layout_gravity="start"     app:layout="@layout/fragment_navigation_drawer"     tools:layout="@layout/fragment_navigation_drawer" />  </android.support.v4.widget.DrawerLayout> 

4 Answers

Answers 1

I solved the issue. As the scroll view was being displayed the bottom was being cut off by the bottom action bar on the actual phone. So to solve this I added padding to the bottom of the scrollview in order to push it back up above the action bar.

The new layout it as follows

Updated working 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" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/coordinatorLayout"> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:fillViewport="true"     android:scrollbars="vertical"     android:paddingBottom="?android:attr/actionBarSize"> <<<-------added this line     <LinearLayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:orientation="vertical">         <android.support.design.widget.TextInputLayout             android:id="@+id/text_input_layout"             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="1">              <EditText                 android:id="@+id/editText"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:hint="Recipe Title"/>         </android.support.design.widget.TextInputLayout>          <TextView             android:id="@+id/ingredientsHeading"             android:layout_below="@+id/text_input_layout"             android:layout_width="fill_parent"             android:layout_height="0dp"             android:text="Ingredients"             android:textStyle="bold|italic"             android:layout_weight="1" />         <ListView             android:id="@+id/ingredientsList"             android:layout_below="@+id/ingredientsHeading"             android:layout_above="@+id/directionsHeading"             android:layout_width="wrap_content"             android:layout_height="195dp"             android:layout_weight="1"></ListView>          <Button style="@style/Button"             android:layout_width="wrap_content"             android:layout_height="0dp"             android:text="Add Ingredient"             android:id="@+id/addIngredient"             android:layout_below="@+id/ingredientsList"             android:enabled="true"             android:layout_gravity="center_horizontal"             android:layout_weight="1" />          <TextView             android:id="@+id/directionsHeading"             android:layout_below="@+id/addIngredient"             android:layout_width="fill_parent"             android:layout_height="0dp"             android:text="Directions"             android:textStyle="bold|italic"             android:layout_weight="1" />         <ListView             android:id="@+id/directionsList"             android:layout_below="@+id/directionsHeading"             android:layout_width="wrap_content"             android:layout_height="195dp"             android:layout_weight="1"></ListView>          <Button style="@style/Button"             android:layout_width="wrap_content"             android:layout_height="0dp"             android:text="Add Direction"             android:id="@+id/addDirection"             android:layout_below="@+id/ingredientsList"             android:enabled="true"             android:layout_gravity="center_horizontal"             android:layout_weight="1" />          <RelativeLayout             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:gravity="center"             android:layout_below="@+id/addDirection">              <Button style="@style/Button"                 android:layout_width="wrap_content"                 android:layout_height="0dp"                 android:text="Add Direction"                 android:id="@+id/showOptionsDialog"                 android:enabled="true"                 android:layout_gravity="center_horizontal"                 android:layout_weight="1" />              <Button style="@style/Button"                 android:layout_width="wrap_content"                 android:layout_height="0dp"                 android:text="Add Direction"                 android:id="@+id/saveRecipe"                 android:enabled="true"                 android:layout_gravity="center_horizontal"                 android:layout_toRightOf="@+id/showOptionsDialog"                 android:layout_weight="1" />           </RelativeLayout>      </LinearLayout>  </ScrollView>   <android.support.design.widget.FloatingActionButton     android:id="@+id/filterButton"     app:backgroundTint="@color/floatingButton"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="bottom|right"     android:clickable="true"     android:src="@drawable/ic_filter"     android:layout_alignParentBottom="true"     android:layout_alignParentEnd="true"     android:layout_marginBottom="63dp"     android:layout_marginRight="16dp" />   </android.support.design.widget.CoordinatorLayout> 

Answers 2

Add these lines in your ScrollView

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true"  android:scrollbars="vertical"> 

Answers 3

You put a weightsum of 1 and your scrollview is 28. You have to put something like that <LinearLayout weightsum=15>(you don't have to put 15) and then what is inside your layout you have to distribute your 15 sum. Like <TextView layout_weight=1> it means that your textview is gonna 1/15. When I use weight I also put the height or the width, depending on which one I want to play, to 0dp. For exemple if I want to play on the width <TextView width=0dp height=wrap_content weight=1>. So you have to give a weight to every child of your LinearLayout. Hope it help.

Edit: Also ListView in a ScrollView is not a good idea, could come from here. Look this post: How can I put a ListView into a ScrollView without it collapsing?

Answers 4

use weightSum for all components in your xml file,

It's android:layout_weight. Weight can only be used in LinearLayout. If the orientation of linearlayout is Vertical, then use android:layout_height="0dp" and if the orientation is horizontal, then use android:layout_width = "0dp". It'll work perfectly.

From your question -- bottom of the layout is being cut off

It is because of fixed height given to components.

EDIT -- xml added

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:padding="5dp"     tools:context="info.androidhive.materialtabs.fragments.OneFragment">      <ScrollView         android:id="@+id/scrollView"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:fadingEdge="none"         android:fillViewport="true"         android:isScrollContainer="true"         android:scrollbars="none">          <LinearLayout             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:orientation="vertical"             android:weightSum="10">              <LinearLayout                 android:layout_width="fill_parent"                 android:layout_height="0dp"                 android:layout_weight="1">                  <android.support.design.widget.TextInputLayout                     android:id="@+id/text_input_layout"                     android:layout_width="match_parent"                     android:layout_height="wrap_content">                      <EditText                         android:id="@+id/editText"                         android:layout_width="match_parent"                         android:layout_height="wrap_content"                         android:hint="Recipe Title" />                 </android.support.design.widget.TextInputLayout>             </LinearLayout>              <LinearLayout                 android:layout_width="fill_parent"                 android:layout_height="0dp"                 android:layout_weight="3.5"                 android:orientation="vertical">                  <TextView                     android:id="@+id/ingredientsHeading"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:padding="5dp"                     android:text="Ingredients"                     android:textStyle="bold|italic" />                  <ListView                     android:id="@+id/ingredientsList"                     android:layout_width="match_parent"                     android:layout_height="wrap_content" />             </LinearLayout>              <LinearLayout                 android:layout_width="fill_parent"                 android:layout_height="0dp"                 android:layout_weight="1"                 android:gravity="center">                  <Button                     android:id="@+id/addIngredient"                     style="@style/AppTheme"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_gravity="center_horizontal"                     android:enabled="true"                     android:text="Add Ingredient" />              </LinearLayout>              <LinearLayout                 android:layout_width="fill_parent"                 android:layout_height="0dp"                 android:layout_weight="3.5"                 android:orientation="vertical">                  <TextView                     android:id="@+id/directionsHeading"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:padding="5dp"                     android:text="Directions"                     android:textStyle="bold|italic" />                  <ListView                     android:id="@+id/directionsList"                     android:layout_width="match_parent"                     android:layout_height="wrap_content" />              </LinearLayout>              <LinearLayout                 android:layout_width="fill_parent"                 android:layout_height="0dp"                 android:layout_weight="1"                 android:gravity="center">                  <Button                     android:id="@+id/addDirection"                     style="@style/AppBaseTheme"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_gravity="center_horizontal"                     android:enabled="true"                     android:text="Add Direction" />             </LinearLayout>         </LinearLayout>     </ScrollView> </LinearLayout> 
Read More