Android studio: TexView in scrollview disapears on scrolling - android-layout

I have a Scrollview inside a linearLayout that contains a vertical Linearlayout.
there is several text view in it and everything is fine , i can see all views.Until i scroll down . Textviews below the screen are not showing.
I changed Textview's alpha to .9 and it worked.
Does anyone know why its like that??
Here is layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back1"
android:alpha="5">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha=".9">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/back35"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageButton7"
android:src="#drawable/can_pot_com"
android:layout_weight="2"
android:scaleType="fitStart"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" >
<Button
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="گلدان با قوطی کنسرو"
android:id="#+id/button6"
android:layout_weight="3"
android:textStyle="bold"
android:textIsSelectable="false"
android:textAlignment="center"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="false"
android:layout_centerInParent="true"
android:background="#00ffffff"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/back35"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageButton"
android:src="#drawable/alphabete_3d1"
android:layout_weight="2"
android:scaleType="fitCenter"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/alphabete_3d"
android:id="#+id/textView"
android:layout_weight="3"
android:textStyle="bold"
android:textIsSelectable="false"
android:textAlignment="center"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentEnd="false"
android:layout_alignParentStart="false"
android:layout_centerInParent="true"
android:background="#00ffffff" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/back35"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageButton2"
android:src="#drawable/kaghaz_aviz_sample"
android:layout_weight="2"
android:scaleType="fitStart"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" >
<Button
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/aviz_kaghazi"
android:id="#+id/textView2"
android:layout_weight="3"
android:textStyle="bold"
android:textIsSelectable="false"
android:textAlignment="center"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="false"
android:layout_centerInParent="true"
android:background="#00ffffff" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/back35"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageButton3"
android:src="#drawable/golden_feather_sample"
android:layout_weight="2"
android:scaleType="fitStart"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" >
<Button
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/aviz_par_tala"
android:id="#+id/button"
android:layout_weight="3"
android:textStyle="bold"
android:textIsSelectable="false"
android:textAlignment="center"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="false"
android:layout_centerInParent="true"
android:background="#00ffffff" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/back35"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageButton4"
android:src="#drawable/button_potsample2"
android:layout_weight="2"
android:scaleType="fitStart"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" >
<Button
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/botton_pot"
android:id="#+id/button2"
android:layout_weight="3"
android:textStyle="bold"
android:textIsSelectable="false"
android:textAlignment="center"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="false"
android:layout_centerInParent="true"
android:background="#00ffffff" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/back35"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageButton5"
android:src="#drawable/canlendersample"
android:layout_weight="2"
android:scaleType="fitStart"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" >
<Button
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/printable_calender"
android:id="#+id/button4"
android:layout_weight="3"
android:textStyle="bold"
android:textIsSelectable="false"
android:textAlignment="center"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="false"
android:layout_centerInParent="true"
android:background="#00ffffff" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#drawable/back35"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:alpha=".9">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" >
<ImageButton
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageButton6"
android:src="#drawable/ballon_pot_sample"
android:layout_weight="2"
android:scaleType="fitStart"
android:background="#00ffffff"
android:cropToPadding="false"
android:foregroundGravity="bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" >
<Button
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/ballon_pot"
android:id="#+id/button5"
android:layout_weight="3"
android:textStyle="bold"
android:textIsSelectable="false"
android:textAlignment="center"
android:lines="3"
android:linksClickable="false"
android:textColor="#000000"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="false"
android:layout_centerInParent="true"
android:background="#00ffffff"
android:alpha="1" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
I'm new to SO if any other thing in necessary pleas let me know.

Related

Android scrollview hiding top widget in layout

Let me tell you first, this is not duplicate question. I have tried every solution from stackoverflow. but nothing work for me.
in my Application, I implementing two gridlayout. first one scroll horizontal and second one scroll vertical. but the problem is when i add scrollview to the second Gridview it hide top content that is my texrview and imagview.
I don't understand. what I am doing wrong.
This is code:
<FrameLayout 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.home.HomeFragment">
<LinearLayout
android:orientation="vertical"
android:weightSum="10"
android:paddingTop="30dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textGrid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:fontFamily="#font/quicksand_bold"
android:paddingStart="20dp"
android:text="Welcome"
android:textColor="#141D50"
android:textSize="34sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/search"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="150dp"
android:src="#android:drawable/ic_search_category_default"
app:tint="#141D50"
tools:ignore="UnknownId" />
</LinearLayout>
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp">
<GridLayout
android:id="#+id/mainGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="8"
android:alignmentMode="alignMargins"
android:columnOrderPreserved="false"
android:numColumns="6"
android:padding="8dp"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardBackgroundColor="#color/colorPrimaryDark"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/street"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/dress"
app:tint="#android:color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="#+id/electricity"
android:layout_gravity="center"
android:fontFamily="#font/quicksand_bold"
android:paddingTop="10dp"
android:text="Dress"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardBackgroundColor="#color/colorPrimaryDark"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/other"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/bags"
app:tint="#android:color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="#+id/electricity"
android:layout_gravity="center"
android:fontFamily="#font/quicksand_bold"
android:paddingTop="5dp"
android:text="Bags"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardBackgroundColor="#color/colorPrimaryDark"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/other1"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/toys"
app:tint="#android:color/white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="#+id/electricity"
android:layout_gravity="center"
android:fontFamily="#font/quicksand_bold"
android:paddingTop="5dp"
android:text="Toys"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</GridLayout>
</LinearLayout>
</HorizontalScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_centerVertical="true"
android:layout_weight="1"
android:fillViewport="true"
android:focusableInTouchMode="true"
app:layout_constrainedHeight="true">
<GridLayout
android:id="#+id/mainGrid1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:alignmentMode="alignMargins"
android:columnCount="2"
android:columnOrderPreserved="false"
android:padding="14dp">
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/electricity1"
android:layout_width="wrap_content"
android:layout_height="104dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/electricity"
android:layout_gravity="center"
android:text="water supply"
android:textAlignment="center"
android:textColor="#141D50"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/water1"
android:layout_width="wrap_content"
android:layout_height="104dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="water supply"
android:textAlignment="center"
android:textColor="#141D50"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/clean1"
android:layout_width="wrap_content"
android:layout_height="104dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Cleanliness"
android:textAlignment="center"
android:textColor="#141D50"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<!-- Column 2 -->
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/street1"
android:layout_width="wrap_content"
android:layout_height="104dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Street"
android:textAlignment="center"
android:textColor="#141D50"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/m"
android:layout_width="wrap_content"
android:layout_height="104dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Other"
android:textAlignment="center"
android:textColor="#141D50"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical">
<ImageView
android:id="#+id/m1"
android:layout_width="wrap_content"
android:layout_height="104dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Other"
android:textAlignment="center"
android:textColor="#141D50"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</GridLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>
It happens, because you written android:layout_weight="1" in RelativeLayout.
First of all, remove android:layout_weight="1" from your RelativeLayout.
Secondly, set RelativeLayout height as a wrap_content.
Before:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
After:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

android studio running code on phone auto turns off.I think there is something wrong in my layout design but i cant figure out why

Android Studio running code on phone auto turns off.
I am trying to build a translator application.
I think there is something wrong in my layout design but I cant figure out what.
I divided my homepage into two parts.
This is my activity_home layout.
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp"
android:background="#drawable/bwall1"
android:fitsSystemWindows="true"
tools:context="nf.co.hoptec.ocr.Home">
<ImageButton
android:id="#+id/fab"
android:layout_width="100dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:background="#drawable/roundcorner"
android:cropToPadding="false"
android:scaleType="fitCenter"
app:layout_constraintHorizontal_bias="0.19"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#drawable/cameraicon"
tools:layout_constraintTop_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="#+id/fab2"
app:layout_constraintTop_toTopOf="#+id/fab2" tools:targetApi="lollipop"/>
<ImageButton
android:id="#+id/fab2"
android:layout_width="100dp"
android:layout_height="100dp"
android:adjustViewBounds="true"
android:background="#drawable/roundcorner"
android:padding="10dp"
android:scaleType="fitCenter"
android:src="#drawable/imageicon"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="72dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="47dp" tools:targetApi="lollipop"/>
<include
layout="#layout/content_home"
android:layout_width="0dp"
android:layout_height="400dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintTop_creator="1" />
</android.support.constraint.ConstraintLayout>
This is my content_home layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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_marginTop="0dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="nf.co.hoptec.ocr.Home"
tools:showIn="#layout/activity_home">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:visibility="visible">
<LinearLayout
android:background="#drawable/border"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:visibility="visible"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/source"
android:layout_width="135dp"
android:layout_height="15dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="1dp"
android:background="#F7F9FC"
android:text=":: Source Language ::"
android:textColor="#000000"
android:textSize="12sp" />
<ImageButton
android:id="#+id/proceedbutt"
android:layout_width="20dip"
android:layout_height="20dip"
android:background="#00ffffff"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/proceed"
android:layout_alignParentEnd="true" />
<ImageButton
android:id="#+id/speakerbutt"
android:layout_width="20dip"
android:layout_height="20dip"
android:background="#00ffffff"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/speaker"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/proceedbutt"/>
<ImageButton
android:id="#+id/copy"
android:layout_width="20dip"
android:layout_height="20dip"
android:background="#00ffffff"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/copy"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/speakerbutt" />
</RelativeLayout>
<EditText
android:id="#+id/ocrtext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30.0dp"
android:layout_marginRight="30.0dp"
android:layout_marginTop="15dp"
android:ems="10"
android:inputType="textMultiLine"
android:selectAllOnFocus="true"
android:singleLine="true"
android:text="Type here to translate"
android:textSize="12sp"
android:layout_marginBottom="15dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible"
android:paddingTop="10dp">
<ImageView
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:id="#+id/ocrimg" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/border"
android:orientation="vertical"
android:visibility="visible">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="#+id/target"
android:layout_width="135dp"
android:layout_height="15dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="1dp"
android:background="#F7F9FC"
android:text=":: Result Language ::"
android:textColor="#000000"
android:textSize="12sp" />
<ImageButton
android:id="#+id/nth"
android:layout_width="20dip"
android:layout_height="20dip"
android:layout_alignParentEnd="true"
android:background="#00ffffff"
app:srcCompat="#drawable/xparent" />
<ImageButton
android:id="#+id/speakerbutt1"
android:layout_width="20dip"
android:layout_height="20dip"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/nth"
android:adjustViewBounds="true"
android:background="#00ffffff"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/speaker" />
<ImageButton
android:id="#+id/copyt"
android:layout_width="20dip"
android:layout_height="20dip"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/speakerbutt1"
android:adjustViewBounds="true"
android:background="#00ffffff"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:srcCompat="#drawable/copy" />
</RelativeLayout>
<TextView
android:id="#+id/ocrtextt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginLeft="30.0dp"
android:layout_marginRight="30.0dp"
android:layout_marginTop="15dp"
android:background="?attr/editTextBackground"
android:ems="10"
android:inputType="textMultiLine"
android:text=""
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Can you tell me what is wrong?
I think its because of constraint layout.Constraint layout is new layout of Android in which you can just drag and drop buttons,textview and all but it may looks perfect in preview but not in your phone because every device have different size of display screen so constraint layout will work different in different android phones and you may also be getting warning or error in that layout file.So try to use LinearLayout or RelativeLayout and then errors will not come.

custom class marquee text restarts while changing another text view in a complex layout

I have own implementation of marquee class since the user can decide the marquee behavior (No scroll, scroll once, scroll repeat) for the text in my music app. The problem arise whenever user starts to play the songs since it continuously update timer text (id:tv_playtime) in the layout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clickable="true"
android:onClick="onButtonHomeClick">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<ImageView
android:layout_width="64.67dp"
android:layout_height="25.33dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="2dp"
android:background="#null"
android:duplicateParentState="true"
android:scaleType="fitStart"
android:visibility="gone" />
</RelativeLayout>
<!--home buttons-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Media Player"
android:textColor="#color/white"
android:textSize="20dp" />
<ImageView
android:id="#+id/iv_settings_btn_passenger"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<!--media player home-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="36dp"
>
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:tint="#color/white"
android:visibility="invisible" />
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
/>
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
/>
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
/>
</RelativeLayout>
<!-- playing indicator-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="370dp"
>
<RelativeLayout
android:layout_width="240dp"
android:layout_height="240dp"
android:layout_centerInParent="true"
android:layout_alignParentTop="true">
<ImageView
android:layout_width="240dp"
android:layout_height="240dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="130dp"
android:layout_marginTop="5dp">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:visibility="gone"/>
<ImageView
android:layout_width="30dp"
android:layout_height="24dp"
android:visibility="gone"/>
<ImageView
android:layout_width="30dp"
android:layout_height="24dp"
android:visibility="gone"/>
<myClass.MarqueeTextView
android:id="#+id/marqueetext1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:clickable="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Song Name"
android:textColor="#android:color/white"
android:textSize="24dp" />
<myClass.MarqueeTextView
android:id="#id/marqueetext2"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_below="#+id/marqueetext1"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:clickable="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Artist Name"
android:textColor="#android:color/white"
android:textSize="18dp" />
<myClass.MarqueeTextView
android:id="#id/marqueetext3"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_below="#+id/marqueetext2"
android:layout_marginLeft="60dp"
android:layout_marginTop="8dp"
android:clickable="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:text="Album Name"
android:textColor="#color/white"
android:textSize="18dp"/>
<TextView
android:id="#+id/tv_playtime"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/marqueetext2"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:text="00.00"
android:textColor="#color/white"
android:textSize="18dp" />
</RelativeLayout>
</RelativeLayout>
<!--media player tracks-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="70dip"
android:visibility="gone">
<ImageView
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="14dip"
/>
<myClass.MarqueeTextView
android:layout_width="match_parent"
android:layout_height="30dip"
android:layout_alignParentBottom="true"
android:layout_marginLeft="14dip"
android:layout_marginRight="5dip"
android:ellipsize="marquee"
android:marqueeRepeatLimit="0"
android:scrollHorizontally="true"
android:singleLine="true"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<!--mood-->
<myClass.GestureView
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<!--gestures-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_alignParentBottom="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="16dp">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_alignParentBottom="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="28dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="20dp"
android:text="00:00"
android:textColor="#android:color/white"
android:textSize="18dp"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="7dip"
android:text="03:50"
android:textColor="#android:color/white"
android:textSize="14dp"
android:textStyle="bold"
android:visibility="gone" />
<SeekBar
style="#style/seekBarMyStyle"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:maxHeight="2dp"
android:minHeight="2dp"
android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="26dip"
android:layout_alignParentTop="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:shadowColor="#color/text_shadow_color"
android:shadowDx="2.5"
android:shadowDy="2.5"
android:shadowRadius="0.01"
android:text="06:18"
android:textColor="#color/white"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/iv_mp_battery"
android:visibility="gone" />
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:visibility="gone" />
<ImageView
android:layout_width="26dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/iv_mp_signal"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
<ImageView
android:layout_width="86dip"
android:layout_height="match_parent"
android:layout_centerVertical="true"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:background="#color/darkbackgroundcoloralpha"
android:layout_width="match_parent"
android:layout_height="176dp"
android:layout_marginTop="50dp"
android:orientation="vertical"
android:visibility="gone" />
</FrameLayout>
I want to control the scrolling behavior of marqueetext1 here, which is working fine when the song is paused (Since timer text field is not updating).
I've tried similar problems but none of them are working for me
TextView restarts Marquee when changing another TextView in same LinearLayout
Setting of TextView stops marquee scrolling of other TextView
Android, RelativeLayout restarts Marquee-TextView when changing ImageView in same RelativeLayout
Note: Am using gestures for media player control (Next, previous, play, pause)
My assumption is its happening because of the layout since I've done a through debugging in custom Marquee class whose properties are not affecting the marquee restart here. I've override onFocusChanged, onWindowFocusChanged and isFocused methods in my derived Marquee class to make the Textview all focused.What am missing here?
My timer was overlapping on marquee text fields; so limiting the width of the timer text view solved the issue.
<TextView
android:id="#+id/tv_playtime"
android:layout_width="50dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/marqueetext2"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:text="00.00"
android:textColor="#color/white"
android:textSize="18dp" />

How to place static positioned button in a co-ordinator layout such that contents don't overlap?

I have created a co-ordinator layout which has an Appcompat button placed at the bottom. I also have a relative layout inside that co-ordinator layout which is inside a nested scroll view. Output I am getting is like the fixed button overlaps the contents of the relative layout which does not let some of the elements inside the relative layout to be viewed. Please help me out guys!
Regards,
Thanks.`
<?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:clipToPadding="false"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".Hashmapretrieval"
app:contentScrim="#000000"
android:fitsSystemWindows="true"
app:statusBarBackground="#android:color/transparent"
android:background="#ffffff"
>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
android:background="#000000"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#000000"
android:background="#000000"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:id="#+id/imagev"
android:background="#000000"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:minHeight="100dp"/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/ns"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<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="wrap_content"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:id="#+id/rr1"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#ffffff"
android:fitsSystemWindows="true"
android:layout_alignParentBottom="true"
android:paddingBottom="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#ffffff">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text=""
android:textSize="15sp"
android:textColor="#000000"
android:id="#+id/placeid" />
<RelativeLayout
android:layout_width="match_parent"
android:id="#+id/rel1"
android:layout_height="0.3dp" android:background="#000000" android:layout_below="#+id/placeid" android:layout_marginTop="20dp">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rel3"
android:background="#ffffff"
android:layout_below="#+id/rel1"
android:layout_marginTop="10dp">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tablelayout"
android:layout_marginTop="10dp"
android:background="#ffffff">
<TableRow android:id="#+id/tableRow1"
android:layout_height="0dp"
android:layout_width="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="17sp"
android:text="Teaching Skills"
android:id="#+id/QF"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Ratings"
android:textSize="17sp"
android:id="#+id/rate1"
android:gravity="center"
android:padding="5dp"
android:layout_weight="0"
/>
</TableRow>
<TableRow android:id="#+id/tableRow2"
android:layout_height="0dp"
android:layout_width="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="17sp"
android:text="Classroom Culture"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
android:id="#+id/QS"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Ratings"
android:textSize="17sp"
android:id="#+id/rate2"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<TableRow android:id="#+id/tableRow3"
android:layout_height="0dp"
android:layout_width="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="17sp"
android:text="Syllabus Covered"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
android:id="#+id/QT"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="No Ratings"
android:textSize="17sp"
android:id="#+id/rate3"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<TableRow android:id="#+id/tableRow4"
android:layout_height="0dp"
android:layout_width="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="17sp"
android:text="Extra help when needed"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
android:id="#+id/QFo"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="No Ratings"
android:textSize="17sp"
android:id="#+id/rate4"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<TableRow android:id="#+id/tableRow5"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_gravity="center_vertical|center_horizontal|center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="17sp"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
android:text="Recommendations"
android:id="#+id/QFi"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="No Ratings"
android:textSize="17sp"
android:id="#+id/rate5"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0.3dp" android:background="#000000" android:layout_marginTop="10dp" android:layout_below="#+id/tr1">
</RelativeLayout>
<TableRow android:id="#+id/tableRow6"
android:layout_height="0dp"
android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="17sp"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
android:text="Overall Ratings"
android:id="#+id/Or"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="No Ratings"
android:textSize="17sp"
android:id="#+id/rateo"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0.3dp" android:background="#000000" android:layout_marginTop="10dp" android:layout_below="#+id/tr2">
</RelativeLayout>
<TableRow
android:layout_height="0dp"
android:layout_width="match_parent" android:padding="15dp"
> </TableRow>
<TableRow android:id="#+id/tableRow7"
android:layout_height="0dp"
android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Fees:"
android:textSize="17sp"
android:id="#+id/tv1"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:textSize="17sp"
android:id="#+id/fees"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<TableRow android:id="#+id/tableRow8"
android:layout_height="0dp"
android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Installment:"
android:textSize="17sp"
android:id="#+id/tv2"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/instavl"
android:layout_below="#+id/fees"
android:layout_weight="0"
android:gravity="center"
android:textSize="17sp"
android:padding="5dp"
/>
</TableRow>
<TableRow android:id="#+id/tableRow9"
android:layout_height="0dp"
android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Duration:"
android:id="#+id/tv3"
android:layout_weight="3"
android:textSize="17sp"
android:gravity="left"
android:padding="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/duration"
android:layout_weight="0"
android:textSize="17sp"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<TableRow android:id="#+id/tableRow10"
android:layout_height="0dp"
android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Group Discount:"
android:textSize="17sp"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:textSize="17sp"
android:id="#+id/groupdiscount"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
<TableRow android:id="#+id/tableRow11"
android:layout_height="0dp"
android:layout_width="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="One Time Discount:"
android:textSize="17sp"
android:id="#+id/tv5"
android:layout_weight="3"
android:gravity="left"
android:padding="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:textSize="17sp"
android:id="#+id/otpdiscount"
android:layout_weight="0"
android:gravity="center"
android:padding="5dp"
/>
</TableRow>
</TableLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="#+id/rr3"
android:layout_below="#+id/tablelayout">
<Button android:id="#+id/add_wishlist"
android:layout_height="#dimen/buttonheight"
android:layout_width="match_parent"
android:onClick="addtowishlist"
android:textAllCaps="false"
android:textSize="#dimen/buttonTextsize"
android:text="Add to my List"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<Button android:id="#+id/book_demo"
android:onClick="bookdemo"
android:layout_height="40dp"
android:clickable="true"
android:layout_width="match_parent"
android:layout_gravity="end|bottom" android:textColor="#ffffff"
android:textSize="#dimen/buttonTextsize"
android:textAllCaps="false"
android:text="Come for Demo Lecture"
android:background="#3b3b3b"
/>
</android.support.design.widget.CoordinatorLayout>
To hide/show FloatingActionButton there are different ways (and examples online), I like the way through a Behavior i.e. like this.
If you dont want the usual overlap, you can try adding a margin bottom of x dp (the eight of the button) to the NestedScrollView by:
android:layout_marginBottom="xdp"

DrawerLayout in main.xml with ScrollView

Hi guys i have this layout...but if my phone is horizontal doesn't work the ScrollView
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/sfondomain" >
<ImageView
android:id="#+id/imageView0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/icon_drawer" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_below="#+id/imageView0"
android:src="#drawable/homelogo" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="167dp"
android:textColor="#FFFFFF"
android:textStyle="bold|italic"
android:text="Prossimo Arrivo"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="#+id/arrivi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tv1"
android:cacheColorHint="#00000000" />
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="327dp"
android:textColor="#FFFFFF"
android:textStyle="bold|italic"
android:text="Prossima Partenza"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="#+id/partenze"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tv2"
android:cacheColorHint="#00000000" />
<ImageView
android:id="#+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:src="#drawable/info" />
</RelativeLayout>
</FrameLayout>
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#drawable/background" >
</ListView>
but i don't know how put a ScrollView.
The layout works fine but when my phone in landscape doesn't scroll
I tried this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/sfondomain" >
<ImageView
android:id="#+id/imageView0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:src="#drawable/icon_drawer" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_below="#+id/imageView0"
android:src="#drawable/homelogo" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="167dp"
android:textColor="#FFFFFF"
android:textStyle="bold|italic"
android:text="Prossimo Arrivo"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="#+id/arrivi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tv1"
android:cacheColorHint="#00000000" />
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="327dp"
android:textColor="#FFFFFF"
android:textStyle="bold|italic"
android:text="Prossima Partenza"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="#+id/partenze"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tv2"
android:cacheColorHint="#00000000" />
<ImageView
android:id="#+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:src="#drawable/info" />
</RelativeLayout>
</FrameLayout>
<ListView
android:id="#+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:background="#drawable/background" >
</ListView>
</android.support.v4.widget.DrawerLayout>
</ScrollView>
This is a logcat http://paste.ubuntu.com/9697890/

Resources