Android - part of layout not showing up - android

So, i got this Layout in XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/product_grid_product"
android:orientation="vertical"
android:layout_width="315dp"
android:layout_height="295dp"
android:background="#color/white"
android:contentDescription="#string/image_content_description" >
<LinearLayout
android:id="#+id/product_content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp">
<LinearLayout
android:id="#+id/product_content_buttons_image"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="130dp" >
<LinearLayout
android:id="#+id/product_content_buttons"
android:orientation="vertical"
android:layout_width="30dp"
android:layout_height="match_parent" >
<ImageButton
android:id="#+id/button_discount"
android:layout_width="30dp"
android:layout_height="0dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="#color/product_discount_gray"
android:src="#drawable/product_discount" />
<ImageButton
android:id="#+id/button_promotion"
android:layout_width="30dp"
android:layout_height="0dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="#color/product_promotion_gray"
android:src="#drawable/product_promotion" />
<ImageButton
android:id="#+id/button_oportunity"
android:layout_width="30dp"
android:layout_height="0dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="#color/product_oportunity_gray"
android:src="#drawable/product_oportinity" />
<ImageButton
android:id="#+id/button_new"
android:layout_width="30dp"
android:layout_height="0dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="#color/product_new_gray"
android:src="#drawable/product_new" />
</LinearLayout>
<LinearLayout
android:id="#+id/product_content_image_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/product_content_image"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/product_content_details"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="#+id/product_content_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:textColor="#color/gray_text"
android:textSize="14sp"
android:text="Panela de Pressão" />
<TextView android:id="#+id/product_content_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/gray_text"
android:textSize="12sp"
android:text="Aço Inox, 1.5L" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="#+id/product_content_brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:textStyle="bold"
android:textColor="#color/gray_text"
android:textSize="14sp"
android:text="Marca" />
<TextView android:id="#+id/product_content_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="right"
android:textStyle="bold"
android:textColor="#color/gray_text"
android:textSize="16sp"
android:text="10000,00€" />
</LinearLayout>
<!-- starting here -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/product_content_ref"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:textStyle="bold"
android:textColor="#color/gray_text"
android:textSize="14sp"
android:text="Ref.: 56065196968" />
<TextView android:id="#+id/product_content_stock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="right"
android:textStyle="bold"
android:textColor="#color/gray_text"
android:textSize="14sp"
android:text="Stock [240]" />
</LinearLayout>
<!-- to here -->
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray_lines"/>
<LinearLayout
android:id="#+id/product_buttons"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="45dp" >
<ImageButton
android:id="#+id/shopping_cart"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#color/white"
android:src="#drawable/shopping_cart" />
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/gray_lines"/>
<ImageButton
android:id="#+id/remove_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#color/white"
android:src="#drawable/remove" />
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/gray_lines"/>
<EditText
android:id="#+id/edit_quantity"
android:layout_width="50dp"
android:layout_height="match_parent"
android:singleLine = "true"
android:background="#color/white"
android:hint="0"
android:gravity="center"
android:textSize="35sp" />
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/gray_lines"/>
<ImageButton
android:id="#+id/add_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#color/white"
android:src="#drawable/add" />
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/gray_lines"/>
<Button
android:id="#+id/observations_button"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#color/white"
android:text="OBS."
android:textSize="25sp"
android:textColor="#color/gray_text" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray_lines"/>
</LinearLayout>
Nevermind the harcoded strings, they're for dummy purposes.
The problem is that anything that I write between the two comments ("starting here" to "to here") is not showing up.
I've tried increasing the height of the layout but it doesn't work.
Any help, please?

The problem is that you have two LinearLayouts both having android:layout_height="match_parent", so that the first one takes all the place.
You should set android:layout_height either to a "wrap_content" or to a fixed value.

It looks like you have the non-appearing LinearLayout on the same level of the hierarchy as another LinearLayout. Both are set to match_parent and the first one is consuming the view area.
Try setting them to either fill_parent or wrap_content.

Related

Facing issue in small Screen sizes

Hii guys here in small screen size i am facing issue in edittext it is not clearly visible but in large screen size it is showing goodThis is a large screen image with 6inchThis is the error once with 5inch screen
Here i post a snippet of code where there are no. of tables which i created using linear layout but in small screen sie its getting hide i have tried making the heigth to wrap content but still its not resolving
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimaryDark1"
app:title="Work Details"
app:titleTextColor="#fff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shramanand Tapsil for the Month: "
android:textColor="#000"
android:textSize="16sp" />
<TextView
android:id="#+id/month121"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textColor="#000"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="100dp"
android:background="#drawable/ic_down"
android:orientation="vertical"
android:weightSum="8.8">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.2"
android:orientation="horizontal"
android:weightSum="4">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.6">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textColor="#android:color/black"
android:textSize="14dp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".8"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Quantity"
android:textColor="#android:color/black"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".9"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hour Multiplier"
android:textColor="#android:color/black"
android:textSize="15sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".7"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Shramanand Hours"
android:textColor="#android:color/black"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".7"
android:orientation="horizontal"
android:weightSum="4">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.6"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="All 1 Day Paid activities "
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".8"
android:gravity="center">
<EditText
android:id="#+id/edt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="__"
android:inputType="number"
android:maxLength="3"
android:paddingLeft="8dp"
android:textColor="#android:color/black"
android:textCursorDrawable="#null"
android:textSize="13sp" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".9"
android:gravity="center">
<TextView
android:id="#+id/txtHours1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="x 6"
android:textColor="#android:color/black"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="right|bottom"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="20dp"
android:background="#drawable/rounded_corner_button_bg"
android:text="Next"
android:textColor="#fff" />
</LinearLayout>
</ScrollView>
</LinearLayout>
You could try setting a wrap_content height on the horizontal LinearLayout of the first row, so that it fits the content, by replacing:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.2"
android:orientation="horizontal"
android:weightSum="4">
with
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4">
It could be because you have hard-coded the text size and it is too large.
I recommend this library (https://github.com/intuit/sdp) for setting the size of the text. It will scale your text size based on screen size.

Dividing and positioning custom layouts equally in android relative layout

This is continuation from my previous question. Layout is changed as given below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black_70_opacity"
android:weightSum="100"
tools:context="com.dell.eventapp.ui.activity.HomeActivity">
<LinearLayout
android:id="#+id/top_image"
android:layout_width="match_parent"
android:layout_height="#dimen/img_height"
android:background="#drawable/activity_background"
android:contentDescription="#string/top_image"
android:orientation="horizontal"
android:scaleType="centerCrop"
android:weightSum="25">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
android:paddingBottom="#dimen/margin_8dp"
android:text="#string/cio_summit_monaco_2015"
android:textColor="#android:color/white"
android:textSize="#dimen/large_font" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_image"
android:layout_below="#id/top_image"
android:orientation="vertical"
android:weightSum="65">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="160sp"
android:layout_marginStart="#dimen/margin_20dp"
android:layout_marginTop="#dimen/margin_30dp"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:id="#+id/agenda"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="#dimen/margin_20dp"
android:layout_weight="1"
android:background="#drawable/activity_background"
android:gravity="center|bottom"
android:paddingBottom="#dimen/margin_10dp"
android:text="#string/agenda"
android:textColor="#android:color/white"
android:textSize="#dimen/medium_font" />
<TextView
android:id="#+id/sessions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="#dimen/margin_20dp"
android:layout_weight="1"
android:background="#drawable/activity_background"
android:gravity="center|bottom"
android:paddingBottom="#dimen/margin_10dp"
android:text="#string/sessions"
android:textColor="#android:color/white"
android:textSize="#dimen/medium_font" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="160sp"
android:layout_marginStart="#dimen/margin_20dp"
android:layout_marginTop="#dimen/margin_30dp"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:id="#+id/speaker"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginRight="#dimen/margin_20dp"
android:layout_weight="1"
android:background="#drawable/activity_background"
android:gravity="center|bottom"
android:paddingBottom="#dimen/margin_10dp"
android:text="#string/speakerbio"
android:textColor="#android:color/white"
android:textSize="#dimen/medium_font" />
<TextView
android:id="#+id/venues"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin_20dp"
android:layout_weight="1"
android:background="#drawable/activity_background"
android:gravity="center|bottom"
android:layout_gravity="center"
android:paddingBottom="#dimen/margin_10dp"
android:text="#string/venues"
android:textColor="#android:color/white"
android:textSize="#dimen/medium_font" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/bottom_image"
android:layout_width="match_parent"
android:layout_height="#dimen/img_height1"
android:layout_alignParentBottom="true"
android:background="#drawable/activity_background"
android:contentDescription="#string/top_image"
android:scaleType="centerCrop"
android:weightSum="10">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:paddingBottom="#dimen/margin_8dp"
android:text="#string/home_content"
android:textColor="#android:color/white"
android:textSize="#dimen/large_font" />
</RelativeLayout>
</RelativeLayout>
In root Relativelayout, I've used android:weightSum="100", in top Linearlayout, I've used android:weightSum="25". In 2nd LinearLayout, I've used android:weightSum="65". In nested LinearLayout, I've used android:weightSum="2". In 3rd LinearLayout, I've used android:weightSum="2". In bottom RelativeLayout, I've used android:weightSum="10". Resulting UI is as given below:
Custom layouts used aren't spaced evenly at top and bottom. How can I do that by using android:weightsum and android:layout_weight?
Please have a look. I hope it will work for you.
<?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">
<ImageView
android:id="#+id/imageview_1"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:background="#33000000"
android:src="#android:drawable/ic_menu_gallery" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imageview_1"
android:gravity="center"
android:text="CIO Summit Monaco 2015"
android:textColor="#000000"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/imageview_2"
android:layout_below="#+id/imageview_1"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageview_11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#33000000"
android:src="#android:drawable/ic_menu_gallery" />
<ImageView
android:id="#+id/imageview_12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#33000000"
android:src="#android:drawable/ic_menu_gallery" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageview_21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#33000000"
android:src="#android:drawable/ic_menu_gallery" />
<ImageView
android:id="#+id/imageview_22"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#33000000"
android:src="#android:drawable/ic_menu_gallery" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageview_2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:background="#33000000"
android:src="#android:drawable/ic_menu_gallery" />
</RelativeLayout>

No scrolling for RecyclerView android Lollipop 5.x

Struggling with RecyclerVivew for Android 5.X ( Lollipop ), I have designed simple layout as:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="4">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvAuditStartDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/to" />
<TextView
android:id="#+id/tvAuditEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvAuditDepartmentName"
style="#style/TextviewPrimaryMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:lines="1" />
<TextView
android:id="#+id/tvSubItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center" />
</LinearLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2">
<TextView
android:id="#+id/tvAuditSubmitDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<CheckBox
android:id="#+id/chkbAuditStatus"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:background="#drawable/check_box"
android:button="#android:color/transparent"
android:clickable="false"
android:gravity="end" />
</FrameLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
And the custom RecyclerView.Adapter is attached to it, with item layout as:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<LinearLayout
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:orientation="horizontal"
android:weightSum="4">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvAuditStartDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/to" />
<TextView
android:id="#+id/tvAuditEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvAuditDepartmentName"
style="#style/TextviewPrimaryMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:lines="1"/>
<TextView
android:id="#+id/tvSubItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center" />
</LinearLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2">
<TextView
android:id="#+id/tvAuditSubmitDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<CheckBox
android:id="#+id/chkbAuditStatus"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:background="#drawable/check_box"
android:button="#android:color/transparent"
android:clickable="false"
android:gravity="end" />
</FrameLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
Now issue with this setup is, the setup is working fine in all the android versions except 5.X as result no scrolling to RecyclerView. Also it is not the only case where no scrolling is observer but the no scrolling is also observed in other Views like Spinner with different observation. In case of Spinners the dropdown List is shown but the selected item is not being reflected on UI.
All the view are inflated within Fragment.
Just try to implement this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="4">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvAuditStartDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/to" />
<TextView
android:id="#+id/tvAuditEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvAuditDepartmentName"
style="#style/TextviewPrimaryMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:lines="1" />
<TextView
android:id="#+id/tvSubItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center" />
</LinearLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2">
<TextView
android:id="#+id/tvAuditSubmitDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<CheckBox
android:id="#+id/chkbAuditStatus"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:background="#drawable/check_box"
android:button="#android:color/transparent"
android:clickable="false"
android:gravity="end" />
</FrameLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
</ScrollView>
</LinearLayout>
I have solved the issue by updating the support library to com.android.support:design:25.2.0. Also don't know the reason behind this and what exactly does it make difference. If any one have found any reason please let all know. It will be helpful. Thank you.

Recycle view row text overlaps on smaller devices

I am building a simple row layout to add data dynamicly inside my recycle view, so i builded a a layout like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cfcfcf">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="#ffffff"
android:orientation="horizontal">
<ImageView
android:id="#+id/plantPhoto"
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#c7c7c7"
android:padding="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="#+id/plantName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="15dp"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/emerald" />
<ImageView
android:id="#+id/starIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:padding="15dp"
android:src="#drawable/ic_star" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="15dp">
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="#+id/data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="#+id/cameraForbiden"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/base" />
<ImageView
android:id="#+id/cameraForbiden"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:src="#drawable/ic_no_photos" />
<ImageView
android:id="#+id/userIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:src="#drawable/ic_user" />
<com.example.afcosta.inesctec.pt.android.Helpers.NexusBoldTextView
android:id="#+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/userIcon"
android:layout_alignBottom="#+id/userIcon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Filipe"
android:textColor="#color/base" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
the main problem on this approach is that when i check my solution on smaller devices the text at left orverlaps the text at right, one solution that i am searching is to decrease the content based on the device size, but didn't find that yet.
This is what i get on a Nexus 5 for example:
this is what i get on a smaller device:
any help with this guys?
Thank you very much
You can use Linear layout for this. You can assign weight to each item.
Try this code :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cfcfcf">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="#ffffff"
android:orientation="horizontal">
<ImageView
android:id="#+id/plantPhoto"
android:layout_width="120dp"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#c7c7c7"
android:padding="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/plantName"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="15dp"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<ImageView
android:id="#+id/starIcon"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:padding="15dp"
android:src="#drawable/ic_art_track_black_24dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/cameraForbiden"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="#drawable/ic_art_track_black_24dp" />
<TextView
android:id="#+id/data"
android:layout_width="0dp"
android:layout_weight="2.5"
android:layout_height="wrap_content"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black" />
<TextView
android:id="#+id/password"
android:layout_width="0dp"
android:layout_weight="2"
android:textAlignment="viewEnd"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/userIcon"
android:layout_alignBottom="#+id/userIcon"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Filipe"
android:textColor="#color/black" />
<ImageView
android:id="#+id/userIcon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:gravity="left"
android:src="#drawable/ic_art_track_black_24dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Understanding layout_weight

I want to do this:
The problem: all of the layout is contain by ScrollView into a LinearLayout and at the bottom must be the buttons of the stepper. To do that i used layout_weight to locating the elements in the space how i want.
Here is my XML code:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:fillViewport="true"
android:background="#drawable/shape_fondo"
android:layout_weight="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:src="#mipmap/indicador_wizzard2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Días de ingesta"
android:layout_marginBottom="6dp"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:weightSum="49">
<ToggleButton
android:id="#+id/lunes"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/botonesdias"
android:textOn="Lu"
android:textOff="Lu"/>
<ToggleButton
android:id="#+id/martes"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/botonesdias"
android:textOn="Ma"
android:textOff="Ma"/>
<ToggleButton
android:id="#+id/miercoles"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/botonesdias"
android:textOn="Mie"
android:textOff="Mie"/>
<ToggleButton
android:id="#+id/jueves"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/botonesdias"
android:textOn="Jue"
android:textOff="Jue"/>
<ToggleButton
android:id="#+id/viernes"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/botonesdias"
android:textOn="Vie"
android:textOff="Vie"/>
<ToggleButton
android:id="#+id/sabado"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/botonesdias"
android:textOn="Sa"
android:textOff="Sa"/>
<ToggleButton
android:id="#+id/domingo"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/botonesdias"
android:textOn="Do"
android:textOff="Do"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2.3"
android:id="#+id/contenedortitulito">
<TextView
android:id="#+id/titulohora"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="Hora" />
<TextView
android:id="#+id/titulodosis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true"
android:text="Dosis"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/listview"
android:background="#color/azul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/contenedortitulito"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
style="#style/botones"
android:id="#+id/btn_cancelar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Atrás"
android:layout_gravity="center"/>
<Button
style="#style/botones"
android:id="#+id/btn_irapaso3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Continuar"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I do not quite understand the concept of layout weight. Can you explain me?
Thanks!
You Need to provide weightsum to parent layout first of all after that you can distribute weight accordingly..
i have provided example of screen in which i used weightsum and layout_weight.
You can apply layout weight on scrollview as well
Here is the code for sample screen.
You can ignore first relative layout.
Hope it Helps
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/whole_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="35dp"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".15"
android:background="#drawable/top"
android:orientation="horizontal"
android:weightSum="6">
<ImageView
android:id="#+id/ivHome"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ll_home" />
<ImageView
android:id="#+id/ivTraderList"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ll_traderlist_green" />
<ImageView
android:id="#+id/ivStatement"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ll_statement_green" />
<ImageView
android:id="#+id/ivSummary"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ll_summary_green" />
<ImageView
android:id="#+id/ivProduct"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ll_product_green" />
<ImageView
android:id="#+id/ivLogout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ll_logout" />
</LinearLayout>
<TextView
style="#style/TitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="#string/trader_list_str" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/lightGreen"
android:orientation="horizontal"
android:weightSum="1">
<EditText
android:id="#+id/etDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".495"
android:editable="false"
android:focusable="false"
android:gravity="center"
android:text="#string/date_str"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
<View
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_weight=".005"
android:background="#android:color/darker_gray" />
<EditText
android:id="#+id/etTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".495"
android:editable="false"
android:focusable="false"
android:gravity="center"
android:text="#string/time_str"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".84"
android:orientation="vertical"
android:weightSum="1">
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".8" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".2"
android:orientation="vertical"
android:weightSum="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#color/lightYellow"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/tvLabelTotal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".595"
android:gravity="center"
android:text="#string/total_str"
android:textAppearance="?android:textAppearanceMedium" />
<View
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_weight=".01"
android:background="#android:color/darker_gray" />
<TextView
android:id="#+id/tvTotal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="1dp"
android:layout_weight=".395"
android:gravity="center" />
</LinearLayout>
<TextView
android:id="#+id/tvOrder"
style="#style/BtnStyle"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:onClick="placeOrder"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:text="#string/place_order_str" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/advtLabel"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_alignParentBottom="true"
android:background="#color/lightYellow"
android:orientation="horizontal" />

Categories

Resources