I have a problem with my CardView and TextInputLayout

CodeFluid

I have a problem with my layout. I have a CardView and inside I have a LinearLayout and inside of my LinearLayout, I have two TextInputLayout and one spinner, here is the code:

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:background="@color/White"
    tools:context=".Fragments.ProductsFragment">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.CardView
                    android:id="@+id/cvRuler"
                    xmlns:card_view="http://schemas.android.com/apk/res-auto"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    card_view:cardBackgroundColor="@color/colorPrimaryDark"
                    card_view:cardCornerRadius="10dp"
                    card_view:cardUseCompatPadding="true">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:orientation="horizontal">

                        <android.support.design.widget.TextInputLayout
                            android:id="@+id/tilCodeBar"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textColorHint="@color/black"
                            app:hintEnabled="true">
                            <EditText
                                android:id="@+id/etBarCode"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="2"
                                android:ems="14"
                                android:hint="Código de Barras"
                                android:inputType="numberDecimal"
                                android:textColor="@color/black"/>
                        </android.support.design.widget.TextInputLayout>

                        <ImageButton
                            android:id="@+id/ibReadCode"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_weight="0.5"
                            android:src="@drawable/ic_camera_light" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:orientation="vertical">

                        <android.support.design.widget.TextInputLayout
                            android:id="@+id/tilDescProduct"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textColorHint="@color/black"
                            app:hintEnabled="true">

                            <EditText
                                android:id="@+id/etDescProduct"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="Descripción del Producto"
                                android:inputType="none"
                                android:textColor="@color/black" />
                        </android.support.design.widget.TextInputLayout>

                    </LinearLayout>

                </android.support.v7.widget.CardView>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

My problem is that when I execute my code, my layout order the TextInputLayout one over another and I get the following image. Is there a solution for this?

enter image description here

AskNilesh

I have a problem with my CardView and TextInputLayout

You need to wrap your both LinearLayout that contains TextInputLayout in to a single viewGroup inside CardView

SAMPLE CODE

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/cvRuler"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    card_view:cardBackgroundColor="@color/colorPrimaryDark"
                    card_view:cardCornerRadius="10dp"
                    card_view:cardUseCompatPadding="true">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_margin="10dp"
                            android:orientation="horizontal">

                            <android.support.design.widget.TextInputLayout
                                android:id="@+id/tilCodeBar"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:textColorHint="@android:color/black"
                                app:hintEnabled="true">

                                <EditText
                                    android:id="@+id/etBarCode"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_weight="2"
                                    android:ems="14"
                                    android:hint="Código de Barras"
                                    android:inputType="numberDecimal"
                                    android:textColorHint="@android:color/black" />
                            </android.support.design.widget.TextInputLayout>

                            <ImageButton
                                android:id="@+id/ibReadCode"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_weight="0.5"
                                android:src="@drawable/ic_close" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_margin="10dp"
                            android:orientation="vertical">

                            <android.support.design.widget.TextInputLayout
                                android:id="@+id/tilDescProduct"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textColorHint="@android:color/black"
                                app:hintEnabled="true">

                                <EditText
                                    android:id="@+id/etDescProduct"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:hint="Descripción del Producto"
                                    android:inputType="none"
                                    android:textColorHint="@android:color/black" />
                            </android.support.design.widget.TextInputLayout>

                        </LinearLayout>

                    </LinearLayout>
                </android.support.v7.widget.CardView>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</FrameLayout>

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I know which button is clicked inside my CardView if I have a dynamic RecyclerView/CardView?

I have problem with my multiplication table,

I have a problem with indentation in my code

I have problem with adding my object to array

I have a problem with my Java remove method

i have wifi problem with my ubuntu suddenly

I have a problem with my number format in php

I have a routing problem on my Angular project

I have a problem with my version of React

i have a problem with my code it wont work

I have a problem with my minesweeper project

i have a problem with my age calculator in python

I have a problem with my stop watch in JavaScript

I have a problem with my "Game of life" on python

I have R Reproducibility problem peculiar to my my windows 10

I have a Problem at my Forms in my wordpress website

i really cant find my problem.. but my problem is that i have something duplicated in my tuple

i have a problem with my c# weighting scale program

I have a problem on running my self coded app on Swift 10.2

i have a problem with logging to my wordpress site using cURL

I have a problem with RTL in special part of my bootstrap theme

I have some problem on scroll snap points with my CSS

I have a problem to create function my database in oracle

I have problem with my function while creating select

I have a problem installing my node module depandances for Angular

I have problem about creating Again my Html elements

I have some problem on uploading Android project to my Github repo

I have a problem in styling my HTML table with external CSS file

I have a problem with the += operator for my string class it is not correctly concatenating the strings