Align LinearLayout at the bottom - android

I want to align a LinearLayout at the bottom. I read many posts of the same problem and I still don't make it. In this post there is a similiar problem. But the answer didn't help me.
My code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:background="#drawable/shape_fondo">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="Hora"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true"
android:text="Dosis"/>
</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>
</LinearLayout>
Help me please I'm going crazy

First change the topmost LinearLayout to have android:layout_height="match_parent"
Then, wrap the 3 layouts above the one you want at the bottom in a parent LinearLayout, with android:layout_height="0dp" and android:layout_weight="1"
Here is the full layout
<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical"
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="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>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="Hora"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_alignParentRight="true"
android:text="Dosis"/>
</RelativeLayout>
<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>
<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>
</LinearLayout>

Related

How to create multiple cardview in Android Studio

I am working on this project and I am designing the layout specifically in adding a product that deals with multiple cards.
The android studio that I am working on has an SDKVersion of 28. I have tried checking out some answers from other posts but none of them helped. In addition, I saw some tutorials on YouTube that you have to use an itemAdapter but it will only show you cards with same information. Mine is different.
The picture below that I designed is the one that I want. However, after executing the my code below, it is only showing the first CardView and nothing about "Discount" CardView when I scroll down on my app which shows on the second picture.
activity_add_product.xml
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AddProductActivity"
android:orientation="vertical"
android:background="#color/colorWhiteBG">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/cv_prod"
android:layout_width="600dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/colorWhite"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product Name"
android:textStyle="bold"
android:textColor="#color/colorDarkText"
android:textSize="#dimen/card_title"/>
<EditText
android:id="#+id/editTextProdName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textAutoComplete"
android:padding="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Category"
android:textColor="#color/colorDarkText"
android:textSize="#dimen/card_title"
android:textStyle="bold"/>
<Spinner
android:id="#+id/spinnerCategory"
android:layout_width="match_parent"
android:layout_height="50dp"
android:entries="#array/prodcategorylist"
android:padding="5dp"></Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:buttonTint="#color/colorPrimary"
android:text="This item is available for sale."/>
</LinearLayout>
<LinearLayout
android:id="#+id/conditionlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:paddingRight="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Condition"
android:textStyle="bold"
android:textSize="#dimen/card_title"
android:textColor="#color/colorDarkText"/>
<Spinner
android:id="#+id/spinnerCondition"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/conditionlist"
android:padding="5dp"></Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Item Count"
android:textSize="#dimen/card_title"
android:textColor="#color/colorDarkText"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextConditionCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:inputType="number"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Quantity of an item according to it's condition."
android:textSize="6dp"
android:layout_marginLeft="20dp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/expirationdatelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:paddingRight="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Expiration Date"
android:textStyle="bold"
android:textSize="#dimen/card_title"
android:textColor="#color/colorDarkText"/>
<EditText
android:id="#+id/spinnerExpiration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="date"
android:padding="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Item Count"
android:textSize="#dimen/card_title"
android:textColor="#color/colorDarkText"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextExpCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:inputType="number"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Quantity of an item according to it's expiration date."
android:textSize="6dp"
android:layout_marginLeft="20dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<ImageView
android:id="#+id/imageaddBtn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_add_circle_black_24dp"
android:tint="#color/colorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:text="ADD EXPIRATION DATE"
android:textColor="#color/colorDarkText" />
</LinearLayout>
<LinearLayout
android:id="#+id/soldbyandunitlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_gravity="center">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sold by"
android:textColor="#color/colorDarkText"
android:textSize="#dimen/card_title"
android:textStyle="bold"
android:layout_gravity="center"/>
<RadioGroup
android:id="#+id/radioGroupSoldBy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_gravity="center"
android:paddingLeft="10dp">
<RadioButton
android:id="#+id/radioBtnEach"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stringEach"
android:buttonTint="#color/colorPrimary"/>
<RadioButton
android:id="#+id/radioBtnWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="#string/stringWeight"
android:buttonTint="#color/colorPrimary"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Unit"
android:textColor="#color/colorDarkText"
android:textSize="#dimen/card_title"
android:textStyle="bold"/>
<Spinner
android:id="#+id/spinnerSoldbyUnit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/unitlist"
android:padding="5dp"></Spinner>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/pricelayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:paddingRight="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Price"
android:textStyle="bold"
android:textSize="#dimen/card_title"
android:textColor="#color/colorDarkText"/>
<EditText
android:id="#+id/editTextPrice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="0.00"
android:padding="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:paddingLeft="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="QR Code"
android:textSize="#dimen/card_title"
android:textColor="#color/colorDarkText"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextQRCode1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:inputType="text"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/cv_discounts"
android:layout_width="600dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/colorWhite"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Discounts"
android:textSize="#dimen/card_title_name"
android:textColor="#color/colorDarkText"
android:textStyle="bold"
android:layout_marginTop="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="In Stock"
android:textStyle="bold"
android:textColor="#color/colorDarkText"
android:textSize="#dimen/card_title" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ROP"
android:textColor="#color/colorDarkText"
android:textSize="#dimen/card_title"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editTextProdInStock"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="number"
android:hint="0"/>
<EditText
android:id="#+id/editTextProdVal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="number"
android:hint="0"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</LinearLayout>

tools:showIn causing error in Android layout

I've searched through the site but haven't found a similar question. I have finished making this layout, and then I proceeded to make some changes in my code (not regarding the layout), and when I came back to content_main.xml, the layout decided not to render. The solution seems to be when I remove this line:
tools:showIn="#layout/activity_main"
Then the layout renders, of course, without the toolbar. The layout is slightly complicated, but it worked fine up until now, and I haven't changed anything in the toolbar layout. Where should I look? In the content_main.xml,activity_main, or where? Also, I can post whatever piece of code might be relevant to this problem. But I do not know what is relevant and what isn't, so instead of posting 500 xml lines of code, (plus 2600 lines in java), I'm not going to post until someone tells me what might be the problem.
EDIT
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.samprocreativecenter.nfc.MainActivity"
android:orientation="horizontal"
android:background="#819fba">
<!-- tools:showIn="#layout/activity_main"
-->
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:background="#drawable/ekran"
android:clickable="false">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="end"
android:id="#+id/txtStatus"
android:textColor="#ffffff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:textSize="28sp"
android:textColor="#ffffff"
android:id="#+id/editUnos"
android:fontFamily="sans-serif-thin"
android:gravity="bottom|end"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:id="#+id/layoutTasteri"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img1"
android:src="#drawable/p1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img2"
android:src="#drawable/p2"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img3"
android:src="#drawable/p3"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img4"
android:src="#drawable/p4"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img5"
android:src="#drawable/p5"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img6"
android:src="#drawable/p6"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img7"
android:src="#drawable/p7"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img8"
android:src="#drawable/p8"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img9"
android:src="#drawable/p9"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/imgNazad"
android:src="#drawable/delete"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/img0"
android:src="#drawable/p0"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/imgEnter"
android:src="#drawable/enter"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_width="30dp"
android:layout_height="match_parent"
android:src="#drawable/linija"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="gone"
android:id="#+id/layoutOtvorenListView"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="18dp"
android:id="#+id/txtSmanjiListView"
android:background="#607b9a"
android:text="Info panel"
android:textColor="#d9e8e7"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/listViewOtvoreni"
android:stackFromBottom="true">
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:id="#+id/layoutSredina">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextClock
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="60sp"
android:id="#+id/textClock"
android:textColor="#ffffff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="27sp"
android:id="#+id/txtDatum"
android:gravity="center"
android:textColor="#ffffff"
android:fontFamily="sans-serif-thin"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:id="#+id/layoutSredinaPodesavanja"
android:visibility="gone"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imgUspesnaVerifikacija"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:text="Domen"
android:id="#+id/domen"
android:textColor="#ffffff"
android:textSize="12sp"/>
<EditText
android:layout_below="#+id/domen"
android:layout_marginTop="2dp"
android:layout_width="match_parent"
android:layout_height="27dp"
android:textColor="#ffffff"
android:background="#drawable/unos_polje_neaktivno"
android:textColorHint="#a6bbce"
android:singleLine="true"
android:maxLines="1"
android:id="#+id/editDomen"/>
<TextView
android:layout_below="#+id/editDomen"
android:layout_marginTop="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/server"
android:text="Adresa servera"
android:textColor="#ffffff"
android:textSize="12sp"/>
<EditText
android:layout_below="#+id/server"
android:layout_marginTop="2dp"
android:layout_width="match_parent"
android:layout_height="27dp"
android:background="#drawable/unos_polje_neaktivno"
android:textColor="#ffffff"
android:maxLines="1"
android:textColorHint="#a6bbce"
android:id="#+id/editServer"/>
<ImageView
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_gravity="end"
android:id="#+id/imgVerifikacija"
android:src="#drawable/verifikacija"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.7"
android:orientation="vertical"
android:id="#+id/layoutSredinaDole"
android:visibility="visible">
<Spinner
android:layout_width="0dp"
android:layout_height="0dp"
android:id="#+id/spnMestoTroska"
android:spinnerMode="dropdown"
android:layout_gravity="start"
>
</Spinner>
<TextView
android:layout_width="120dp"
android:layout_height="70dp"
android:layout_gravity="center"
android:background="#drawable/mesto_troska"
android:id="#+id/txtSpinner"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="18dp"
android:background="#drawable/rsz_prologin_pocetna_1"
android:id="#+id/txtListView"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/listView">
</ListView>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/layoutDesniPodesavanja"
android:visibility="gone"
>
<TextView
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="Rezim sinhronizacije"
android:textSize="13sp"
android:textColor="#a6bbce"
android:id="#+id/rezim"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:textSize="13sp"
android:textColor="#ffffff"
android:id="#+id/txtSinhronizacija"
android:layout_below="#+id/rezim"/>
<ImageView
android:layout_marginStart="5dp"
android:layout_width="55dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_alignTop="#+id/rezim"
android:id="#+id/imgSinhronizuj"
android:src="#drawable/sinhronizuj"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:singleLine="true"
android:layout_below="#+id/imgSinhronizuj"
android:textSize="9sp"
android:text="Sinhronizuj"
android:layout_alignStart="#+id/imgSinhronizuj"
android:layout_marginStart="8dp"
android:id="#+id/sinhronizuj"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rezim rada terminala:"
android:textColor="#a6bbce"
android:layout_marginStart="10dp"
android:textSize="13sp"
android:layout_below="#+id/sinhronizuj"
android:layout_marginTop="15dp"
android:id="#+id/rezimrada"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtTipRV"
android:layout_below="#+id/rezimrada"
android:layout_alignStart="#+id/rezimrada"
android:layout_marginStart="10dp"
android:textColor="#ffffff"
/>
<ImageView
android:layout_width="55dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="15dp"
android:layout_marginBottom="15dp"
android:id="#+id/imgOdustani"
android:src="#drawable/odustani" />
<ImageView
android:layout_width="55dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="15dp"
android:layout_marginStart="15dp"
android:id="#+id/imgSacuvaj"
android:src="#drawable/snimi"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtKoristiMT"
android:layout_below="#+id/txtTipRV"
android:layout_alignStart="#+id/txtTipRV"
android:textColor="#ffffff"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtGPS"
android:layout_below="#+id/txtKoristiMT"
android:layout_alignStart="#+id/txtKoristiMT"
android:textColor="#ffffff"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtSlika"
android:layout_below="#+id/txtGPS"
android:layout_alignStart="#+id/txtGPS"
android:textColor="#ffffff"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txtDozTestaturu"
android:layout_below="#+id/txtSlika"
android:layout_alignStart="#+id/txtSlika"
android:textColor="#ffffff"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/layoutDesni"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9">
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:id="#+id/imgDolazak"
android:src="#drawable/dolazak"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/imgOdlazak"
android:src="#drawable/odlazak"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/imgPauza"
android:src="#drawable/pauza"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/imgTeren"
android:src="#drawable/rad_teren"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/imgPrivatno"
android:src="#drawable/privatno"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Pauza"
android:textColor="#ffffff"
android:textSize="10sp"
android:src="#drawable/pauza"
android:gravity="center"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/rad_teren"
android:text="Rad na terenu"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="10sp"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/privatno"
android:text="Privatno odsutan"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="10sp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.17">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="70dp"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:id="#+id/imgView"
android:layout_marginStart="5dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginStart="1dp">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#a6bbce"
android:text="Poslednji prijavljeni"
android:textSize="12sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/txtPoslenjiUpisani"
android:textColor="#ffffff"
android:text=""
android:textSize="12sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#a6bbce"
android:text="Pozicija"
android:textSize="12sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/txtPoslednjeMestoTroska"
android:textColor="#ffffff"
android:text=""
android:textSize="12sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#a6bbce"
android:text="Vreme"
android:textSize="12sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#ffffff"
android:id="#+id/txtPoslenjeVreme"
android:text=""
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
<TextureView
android:layout_width="0.1dp"
android:layout_height="0.1dp"
android:id="#+id/texture"
android:layout_gravity="center"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:layout_marginTop="4dp">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:id="#+id/imgScrollLevo"
android:src="#drawable/levo"/>
<HorizontalScrollView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_weight="5"
android:id="#+id/horScrollView"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:id="#+id/layoutZaposleni"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:id="#+id/imgScrollDesno"
android:src="#drawable/desno"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
And yes, I am aware that nested weights can be an issue, but this is still a test build. All the drawables exist and work.

i am getting issue for screen sizes 5.5 or above

my xml layout is working fine, everything coming in single screen no need to scroll in below 5.5 screens
but in 5.5 not able to see all thing in single screen i have to scroll to see remaining content that is two buttons showing bottom `
This is the screenshot.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/layout_container"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/left_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:src="#drawable/left_arrow" />
<TextView
android:id="#+id/date_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="5"
android:gravity="center_horizontal"
android:paddingLeft="60dp"
android:paddingRight="60dp"
android:text="Monday, 24 August, 2015"
android:textColor="#color/White" />
<ImageView
android:id="#+id/right_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
android:src="#drawable/right_arrow" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/morning_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/morning_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/morning_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/morning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Morning"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/noon_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/noon_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/noon_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/noon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Noon"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/evening_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
android:paddingBottom="6dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/evening_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/evening_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/evening"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Evening"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/night_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="#drawable/inactive_box"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/night_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/night_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/night"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Night"
android:textColor="#color/SlateGray" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:id="#+id/tab_list4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/pillbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:background="#drawable/pill_box_icon" />
<TextView
android:id="#+id/pill_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pill Box"
android:textColor="#color/White"
android:textSize="13dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="right"
android:orientation="vertical">
<ImageView
android:id="#+id/plus_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/plus_icon" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

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

Custom AlertDialog is taking all screen

I'm building an alertdialog to make a pre-payment summary. The problem is this alertdialog is taking all the screen instead of wrapping the content.
I've tried:
to turn the layout_height and layout_width of the first view of my layout to wrap_content
to use AlertDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE)
Activity code:
LayoutInflater inflater = BasketActivity.this.getLayoutInflater();
View layout = inflater.inflate(R.layout.dialog_pre_payment, null, false);
/* Set all TextView values here ....*/
Builder builder = new Builder(BasketActivity.this);
builder.setView(layout);
/* Avoid Double Pop-up */
if (payDialog != null && payDialog.isShowing()) {
payDialog.dismiss();
}
payDialog = builder.create();
payDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
payDialog.show();
dialog_pre_payment.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/border_grey"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="10"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/basket"
style="#style/list_key"
android:textStyle="bold"
android:layout_marginTop="20dp"/>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="#drawable/border_grey"
android:layout_marginTop="5dp"
android:padding="15dp"
>
<ListView android:id="#+id/priced_basket"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
>
</ListView>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:gravity="bottom"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="bottom">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Total:"
android:textStyle="bold"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/total_priced_list"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textStyle="bold"
android:gravity="right"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/beneficiary"
android:textStyle="bold"
android:layout_marginTop="20dp"
style="#style/list_key"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#drawable/border_grey"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:padding="15dp">
<ImageView android:id="#+id/customer_pic"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/user_pic"/>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView android:id="#+id/card_name"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
<TextView android:id="#+id/card_email"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/border_grey"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:padding="15dp"
>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/amount"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/basket_total_price"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textColor="#color/neutral"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/previsional_balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance_after_payment"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:layout_gravity="right"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_height="40dp"
android:layout_width="match_parent"
android:weightSum="2"
android:gravity="center_horizontal">
<Button android:id="#+id/btn_cancel"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/cancel"
style="#style/CheckBalanceButton"
/>
<Button android:id="#+id/btn_validate"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/pay"
style="#style/PayButton"/>
</LinearLayout>
Al Blanc. Add a dummy Relativelayout around your actual code with height and width match_parent. I always used this technique.
Here is your modified code to give you an idea.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerInParent="true"
android:background="#drawable/border_grey"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="10"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/basket"
style="#style/list_key"
android:textStyle="bold"
android:layout_marginTop="20dp"/>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="#drawable/border_grey"
android:layout_marginTop="5dp"
android:padding="15dp"
>
<ListView android:id="#+id/priced_basket"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
>
</ListView>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:gravity="bottom"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="bottom">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Total:"
android:textStyle="bold"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/total_priced_list"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textStyle="bold"
android:gravity="right"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/beneficiary"
android:textStyle="bold"
android:layout_marginTop="20dp"
style="#style/list_key"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#drawable/border_grey"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:padding="15dp">
<ImageView android:id="#+id/customer_pic"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/user_pic"/>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView android:id="#+id/card_name"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
<TextView android:id="#+id/card_email"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/border_grey"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:padding="15dp"
>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/amount"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/basket_total_price"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textColor="#color/neutral"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/previsional_balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance_after_payment"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:layout_gravity="right"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_height="40dp"
android:layout_width="wrap_content"
android:weightSum="2"
android:gravity="center_horizontal">
<Button android:id="#+id/btn_cancel"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/cancel"
style="#style/CheckBalanceButton"
/>
<Button android:id="#+id/btn_validate"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/pay"
style="#style/PayButton"/>
</LinearLayout>
</RelativeLayout>
Instead of calling the setView method on the AlertDialog.Builder instance, call the setView method on the AlertDialog instance. Like so:
payDialog = builder.create();
payDialog.setView(layout, 0, 0, 0, 0);
payDialog.show();
This should set the padding on the dialog to zero.

Categories

Resources