App shows a different activity layout when launched for the first time - android-studio

I'm sorry for the confusion for the title but this is what happens
This is what the app looks like and it works fine.
HOWEVER...
When the app is launched everytime it shows this.
For some weird reason the card view stretches. This only happens everytime you open the app. It goes back to normal when you tap on assessment then go back.
I don't know what to do because my xml codes is all working as intended on the first photo and I don't know what causes this problem.
CODE:
<TextView
android:id="#+id/title_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="12dp"
android:text=" "
android:textColor="#fff"
android:fontFamily="#font/ness"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/title_view2"
android:layout_width="294dp"
android:layout_height="58dp"
android:layout_below="#+id/title_view"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="65dp"
android:layout_marginTop="45dp"
android:layout_marginEnd="52dp"
android:layout_marginBottom="112dp"
android:fontFamily="#font/ness"
android:text="What do you want to do today?"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/title_view"
android:layout_margin="100dp"
android:columnCount="2"
android:rowCount="3">
<androidx.cardview.widget.CardView
android:id="#+id/assess_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/asses" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Assessment"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/profile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/profile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</GridLayout>

Do you need grid layout in this ui? And your android:columnCount="2" and android:rowCount="3" it's can be reason. Maybe you should use constraintlayout.
UPDATED
Try code below, maybe it can solve your problem.
Also I have seen you used RelativeLayout, for now day it's deprecated and google recommend to use constraintlayout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/title_view2"
android:layout_width="294dp"
android:layout_height="58dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:fontFamily="#font/ness"
android:text="What do you want to do today?"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="#+id/assess_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="#+id/title_view2"
app:layout_constraintStart_toStartOf="#+id/title_view2"
app:layout_constraintTop_toBottomOf="#+id/title_view2">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/asses" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Assessment"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/profile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginTop="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="#+id/assess_menu"
app:layout_constraintStart_toStartOf="#+id/assess_menu"
app:layout_constraintTop_toBottomOf="#+id/assess_menu">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/profile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

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"
>

Nested textview not visible on device, but visible in Design mode

The apps top component has 4 TableRows under a TableLayout and each has a nested TextView and a Switch.
Each of these is set to Visibility:visible
And they show as expected in the Design mode for all available resolutions say NexusS(4.0,480x800,hdpi)
but when started on my Marshmallow device of the same resolution and size, only the switches show up and in their correct positions, those 4 textviews dissappear..
(http://i.stack.imgur.com/xmPqk.png)
(http://i.stack.imgur.com/6UNBo.png)![on device]
Heres the relevant xml
<?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:id="#+id/MainPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bb"
android:hapticFeedbackEnabled="false"
android:minHeight="320dp"
android:minWidth="240dp"
android:visibility="visible"
tools:context=".MainActivity">
<Button
android:id="#+id/play"
android:layout_width="120dp"
android:layout_height="34dp"
android:layout_marginBottom="188dp"
android:layout_marginEnd="205dp"
android:layout_marginStart="24dp"
android:background="#ad000000"
android:hapticFeedbackEnabled="false"
android:text="#string/playBtn"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textStyle="bold"
android:typeface="monospace"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.272"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="#+id/settings"
android:layout_width="120dp"
android:layout_height="38dp"
android:layout_marginTop="8dp"
android:background="#ad000000"
android:hapticFeedbackEnabled="false"
android:text="#string/setBtn"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textStyle="bold"
android:typeface="monospace"
android:visibility="visible"
app:layout_constraintStart_toStartOf="#+id/play"
app:layout_constraintTop_toBottomOf="#+id/play" />
<Button
android:id="#+id/quit"
android:layout_width="120dp"
android:layout_height="38dp"
android:layout_marginTop="8dp"
android:background="#ad000000"
android:hapticFeedbackEnabled="false"
android:text="#string/quitBtn"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textStyle="bold"
android:typeface="monospace"
android:visibility="visible"
app:layout_constraintStart_toStartOf="#+id/settings"
app:layout_constraintTop_toBottomOf="#+id/settings" />
<TextView
android:id="#+id/Title"
android:layout_width="wrap_content"
android:layout_height="178dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:fontFamily="#font/owaw"
android:textColor="#android:color/white"
android:textSize="120sp"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/play"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.418"
tools:text="#string/app_name" />
<TableLayout
android:id="#+id/OptionsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/black"
android:gravity="center_vertical|start"
android:orientation="vertical"
android:paddingEnd="0dp"
android:paddingStart="100dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/Title"
app:layout_constraintVertical_bias="0.0">
<TableRow
android:id="#+id/Option1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="24dp"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/Option2"
app:layout_constraintEnd_toEndOf="#+id/Option2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/Option2"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible"
tools:text="#string/opt1" />
<Switch
android:id="#+id/tutorialSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:allowUndo="true"
android:alpha="0.8"
android:background="#android:color/black"
android:checked="true"
android:hapticFeedbackEnabled="false"
android:padding="0dp"
android:showText="false"
android:splitTrack="false"
android:switchMinWidth="20dp" />
</TableRow>
<TableRow
android:id="#+id/Option2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/Option3"
app:layout_constraintEnd_toEndOf="#+id/Option3"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/Option3"
app:layout_constraintTop_toBottomOf="#+id/Option1">
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible"
tools:text="#string/opt2" />
<Switch
android:id="#+id/musicSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:layout_marginEnd="-70dp"
android:allowUndo="true"
android:alpha="0.8"
android:background="#android:color/black"
android:checked="true"
android:hapticFeedbackEnabled="false"
android:padding="0dp"
android:showText="false"
android:splitTrack="false"
android:switchMinWidth="20dp" />
</TableRow>
<TableRow
android:id="#+id/Option3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/Option4"
app:layout_constraintEnd_toEndOf="#+id/Option4"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/Option4"
app:layout_constraintTop_toBottomOf="#+id/Option2">
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible"
tools:text="#string/opt3" />
<Switch
android:id="#+id/hapticSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:allowUndo="true"
android:alpha="0.8"
android:background="#android:color/black"
android:checked="false"
android:hapticFeedbackEnabled="false"
android:padding="0dp"
android:showText="false"
android:splitTrack="false"
android:switchMinWidth="20dp" />
</TableRow>
<TableRow
android:id="#+id/Option4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/Option5"
app:layout_constraintEnd_toEndOf="#+id/Option5"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/Option5"
app:layout_constraintTop_toBottomOf="#+id/Option3">
<TextView
android:layout_width="150dp"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible"
tools:text="#string/opt4" />
<Switch
android:id="#+id/sfxSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:allowUndo="true"
android:alpha="0.8"
android:background="#android:color/black"
android:checked="true"
android:hapticFeedbackEnabled="true"
android:padding="0dp"
android:showText="false"
android:splitTrack="false"
android:switchMinWidth="20dp" />
</TableRow>
<TableRow
android:id="#+id/Option5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/Option4">
<TextView
android:id="#+id/saveOption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="60dp"
android:layout_marginTop="20dp"
android:clickable="true"
android:focusable="true"
android:hapticFeedbackEnabled="false"
android:paddingBottom="20dp"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="visible"
tools:text="#string/opt5" />
</TableRow>
</TableLayout>
</android.support.constraint.ConstraintLayout>
UPDATE:
I added the font family property to each of those and now the text is visible on device but I dont understand how it matters, since there is already a default option there.

xml change side by side elements

I have this xml. The problem is the things are side by side and I'd like they this way:
CircleImageView - shareName // line break
shareTextViewPublisher // line break
shareimageViewHero // line break
but they are all in the same line. how to do this?
<LinearLayout
android:id="#+id/shareTable"
android:layout_width="match_parent"
android:layout_margin="50dp"
android:padding="10dp"
android:visibility="gone"
android:background="#drawable/border"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:id="#+id/sharePic"
android:paddingBottom="10dp"
android:paddingLeft="1dp" />
<TextView
android:id="#+id/shareName"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:paddingLeft="1dp"
android:layout_weight="1"
/>
<TextView
android:id="#+id/shareTextViewPublisher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="10dp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:padding="0dp"
android:id="#+id/shareimageViewHero"
android:adjustViewBounds="true"/>
</LinearLayout>
If you want to do this using LinearLayout you should put your CircleImageView and shareName in additional horizontal LinearLayout. The structure of the XML should like this:
<LinearLayout
android:id="#+id/shareTable"
android:layout_width="match_parent"
android:layout_margin="50dp"
android:padding="10dp"
android:background="#drawable/border"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:id="#+id/sharePic"
android:paddingBottom="10dp"
android:paddingLeft="1dp" />
<TextView
android:id="#+id/shareName"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:paddingLeft="1dp"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:id="#+id/shareTextViewPublisher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="10dp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:padding="0dp"
android:id="#+id/shareimageViewHero"
android:adjustViewBounds="true"/>
</LinearLayout>

How do I remove the extra space in this recyclerview element in Android?

I'm implementing a Recycler View in Android to create a list, but for some reason I see a space in between two elements, and I'm not able to pinpoint the error location. As to why is this happening, my guess is on the row element XML.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview1="http://schemas.android.com/apk/res-auto"
android:id="#+id/row_top_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/pos_cv"
android:layout_width="match_parent"
android:layout_height="72dp"
android:clickable="true"
cardview1:cardCornerRadius="6dp"
cardview1:cardElevation="4dp"
cardview1:cardMaxElevation="6dp">
<TextView
android:id="#+id/manager1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="15dp"
android:text="Store Manager/Branch"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal">
<TextView
android:id="#+id/retail"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:text="Abc Retail"
android:textSize="10sp" />
<View
android:layout_width="170dp"
android:layout_height="match_parent" />
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="25,000"
android:textColor="#color/colorDarkPink"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/address"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="50dp"
android:text="Abc Retail"
android:textSize="10sp" />
</android.support.v7.widget.CardView>
RecyclerView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/list_view_header_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:weightSum="5"
android:background="#color/colorDarkPink"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top 3 Performers"
android:textStyle="bold"
android:textColor="#color/colorPrimaryLight"
android:layout_weight="3"
android:textSize="16sp"
android:lines="1"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sales"
android:textStyle="bold"
android:textColor="#color/colorPrimaryLight"
android:layout_weight="2"
android:textSize="16sp"
android:lines="1"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/performer_lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#color/colorTransparent"
android:layout_marginTop="16dp"
android:dividerHeight="4dp"
/>
It is because of recycler view height. Try to change recyclerview height to wrap_content.And in cardview layout in linear-layout use height wrap_content.
try this code for your cardview:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview1="http://schemas.android.com/apk/res-auto"
android:id="#+id/row_top_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/pos_cv"
android:layout_width="match_parent"
android:layout_height="72dp"
android:clickable="true"
android:layout_marginBottom="10dp"
cardview1:cardCornerRadius="6dp"
cardview1:cardElevation="4dp"
cardview1:cardMaxElevation="6dp">
<TextView
android:id="#+id/manager1"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="15dp"
android:text="Store Manager/Branch"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal">
<TextView
android:id="#+id/retail"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:text="Abc Retail"
android:textSize="10sp" />
<View
android:layout_width="170dp"
android:layout_height="match_parent" />
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="25,000"
android:textColor="#color/colorDarkPink"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="#+id/address"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="50dp"
android:text="Abc Retail"
android:textSize="10sp" />
</android.support.v7.widget.CardView>
</LinearLayout>
Try to decrease your values
android:layout_height="50dp"
if it will not work try to decrease values in other views

how to design responsive image button & layout by using android studio?

i am new to android development . I designed one parking app , but the layout is not responsive to all mobile devices.
I tried to make responsive image buttons by using 9patch png images & by taking different drawable folder(hdpi,mdpi,xhdpi) . But both are not working for large screen devices.
This is one sample xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/exit"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:src="#drawable/exit1"
android:onClick="on_Bexit"
android:layout_alignTop="#+id/home0"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/home0"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:src="#drawable/home1"
android:onClick="on_Bhome0"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/car"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:src="#drawable/c4"
android:onClick="on_Bcar"
android:cropToPadding="true"
android:nestedScrollingEnabled="true"
android:layout_alignBottom="#+id/textView5"
android:layout_alignLeft="#+id/bike"
android:layout_alignStart="#+id/bike" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/bike"
android:layout_gravity="center_vertical"
android:src="#drawable/b3"
android:background="#android:color/transparent"
android:onClick="on_Bbike"
android:layout_above="#+id/exit"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="ENTRY "
android:id="#+id/textView"
android:textColor="#8dacbe"
android:textStyle="bold"
android:textSize="35dp"
android:layout_above="#+id/car"
android:layout_toLeftOf="#+id/textView6"
android:layout_toStartOf="#+id/textView6" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/bike_count"
android:text="90"
android:textColor="#140441"
android:textSize="30dp"
android:textStyle="bold|italic"
android:layout_alignBottom="#+id/bike"
android:layout_toLeftOf="#+id/exit"
android:layout_toStartOf="#+id/exit"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/car_count"
android:text="120"
android:textStyle="bold|italic"
android:textColor="#140441"
android:textSize="30dp"
android:layout_alignBottom="#+id/car"
android:layout_alignRight="#+id/bike_count"
android:layout_alignEnd="#+id/bike_count" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView5"
android:visibility="invisible"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/T_areadis"
android:hint="Parking area id and name"
android:textColor="#8dacbe"
android:text="kharghar"
android:textSize="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="PAGE"
android:id="#+id/textView6"
android:textColor="#005384"
android:textSize="40dp"
android:textAlignment="center"
android:fontFamily="#string/abc_action_bar_home_description"
android:textStyle="bold"
android:layout_alignTop="#+id/textView"
android:layout_toRightOf="#+id/car_count"
android:layout_toEndOf="#+id/car_count" />
</RelativeLayout>
Please kindly help me out.
Large screen devices use xxhdpi.
How to has equal width
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/exit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bexit"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ENTRY "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#8dacbe"
android:textSize="35dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/home0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bhome0"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/bike_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="90"
android:textColor="#140441"
android:textSize="30dp"
android:textStyle="bold|italic" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/car"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bcar"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/car_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="120"
android:textColor="#140441"
android:textSize="30dp"
android:textStyle="bold|italic" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/bike"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bbike"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/T_areadis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Parking area id and name"
android:text="kharghar"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#8dacbe"
android:textSize="30dp" />
</LinearLayout>

Resources