Android UI design, remove gap between two layouts - android

I'm trying to add a header to my layout and I don't want the gap between two layouts.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linearLayoutContainer"
android:gravity="center">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fixed Header"
android:textColor="#ff00ff"
android:background="#00ff00" />
<ScrollView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:id="#+id/scrollView">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayoutContainer"
android:gravity="center">
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_top_bg"
android:padding="10dp"
android:hint="نــام"
android:textColorHint="#bbbbbb" />
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_default_bg"
android:padding="10dp"
android:hint="نام خانوادگي"
android:textColorHint="#bbbbbb" />
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etNCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_default_bg"
android:padding="10dp"
android:hint="کد ملي"
android:textColorHint="#bbbbbb" />
<EditText
android:gravity="center|center_vertical"
android:id="#+id/etMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edittext_bottom_bg"
android:padding="10dp"
android:hint="شماره همراه"
android:textColorHint="#bbbbbb" />
<View
style="#style/Gap" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayoutRegisterCancel"
android:layout_gravity="clip_vertical"
android:gravity="center">
<Button
android:id="#+id/btnCancel"
android:layout_width="100px"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="بي خيال"
style="#style/DefaultButtonText"
android:background="#drawable/button_default_bg"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/btnRegister"
android:layout_width="100px"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="تمومه"
style="#style/DefaultButtonText"
android:background="#drawable/button_default_bg"
android:gravity="center_vertical|center_horizontal" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
As you can see in the following image, there's gap between "Fixed Header" text view and the main layout. How can I remove this gap?

Change your scrollview android:padding="10dp" to
android:paddingTop="10dp"
android:paddingBottom="10dp"

Related

Fill android layout xamarin

I got trouble with android layout in xamarin. How to fill space without overlapping the layout in android xml?
This layout confusing me. Because it's not like php or xaml. I want to make the layout view like this:
I'm using nexus 6 in design windows. When I ran the debug in emulator the view become like this:
The layout overlapping. I wonder how to fill blank space in android layout size so it can fit in my device (dynamically)?
This is my code:
<?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">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/main_content"
android:gravity="fill_horizontal|bottom">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="610.3dp"
android:layout_weight="1"
android:gravity="center|bottom">
<TextView
android:text="Location Detail"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView9"
android:layout_marginTop="10dp"
android:gravity="center" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="199.3dp"
android:id="#+id/linearLayout1"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout2">
<TextView
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailName" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout3"
android:layout_marginTop="5dp">
<TextView
android:text="Address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView4"
android:width="100dp"
android:gravity="center|left|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView5"
android:gravity="center|top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailAddress" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout4"
android:layout_marginTop="5dp"
android:gravity="top">
<TextView
android:text="Description"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView6"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView7"
android:gravity="center|top" />
<EditText
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailDescription" />
</LinearLayout>
</LinearLayout>
<TextView
android:text="Registered User"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView8"
android:layout_marginTop="10dp"
android:gravity="center" />
<android.support.v7.widget.RecyclerView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="#+id/recyclerViewLocationUser"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/progressBarLocationDetail"
android:layout_marginTop="20dp" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="50dp"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff03a9f4"
android:layout_gravity="right"
android:gravity="center">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Is there something I can do?
Thanks in advance :)
Use this xaml file & compare with your file so that you will get idea what mistake you was making
I realize the issue was using android:gravity (in second & third LinearLayout) along with android:weight which was pushing your layout toward top.
<?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">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/main_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="610.3dp">
<TextView
android:text="Location Detail"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView9"
android:layout_marginTop="0dp"
android:gravity="center" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="199.3dp"
android:id="#+id/linearLayout1"
android:layout_marginTop="0dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout2">
<TextView
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailName" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/linearLayout3"
android:layout_marginTop="5dp">
<TextView
android:text="Address"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView4"
android:width="100dp"
android:gravity="center|left|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView5"
android:gravity="center|top" />
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailAddress" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout4"
android:layout_marginTop="5dp"
android:gravity="top">
<TextView
android:text="Description"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView6"
android:width="100dp"
android:gravity="left|center|top" />
<TextView
android:text=":"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView7"
android:gravity="center|top" />
<EditText
android:inputType="textMultiLine"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/editTextLocationDetailDescription" />
</LinearLayout>
</LinearLayout>
<TextView
android:text="Registered User"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView8"
android:layout_marginTop="10dp"
android:gravity="center" />
<android.support.v7.widget.RecyclerView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="#+id/recyclerViewLocationUser"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/progressBarLocationDetail"
android:layout_marginTop="20dp" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="50dp"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff03a9f4"
android:layout_gravity="right"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

virtual keyboard hides only one edittext

So I have 5 EditText's and the virtual soft keyboard work almost fine with the windowSoftInputMode="adjustPan" but the 4th EditText element is hidden (by the keyboard) when I hit 'next' to go to the next edit text.
*only when I start writing the UI gets up and I can see the EditText
XML Code: (The problematic element is the EditText with 'email' id.)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:minWidth="25px"
android:minHeight="25px"
android:weightSum="5">
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/user_container"
android:gravity="right"
android:layout_weight="0">
<TextView
android:text="Register"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:id="#+id/textView1"
android:textColor="#FFFFFF"
android:gravity="right" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1"
android:background="#ffffff"
android:layout_weight="0">
<ImageView
android:src="#drawable/logo_full"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:padding="40dp"
android:id="#+id/imageView1" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:id="#+id/linearLayout2"
android:gravity="top"
android:layout_weight="3">
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/keycode_container"
android:gravity="center"
android:layout_marginBottom="0.5dp"
android:layout_weight="1">
<ImageView
android:src="#drawable/keycodelogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/keycode_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/keycode"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#id/keycode_lable"
android:inputType="text"
android:hint="קוד רישום"
android:gravity="right"
android:textColorHint="#d9e5f3"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/user_container"
android:gravity="center"
android:layout_weight="1">
<ImageView
android:src="#drawable/userlogo"
android:layout_width="22dp"
android:layout_height="22.0dp"
android:id="#+id/user_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/user"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#id/user_lable"
android:hint="#string/username"
android:inputType="text"
android:textColorHint="#d9e5f3"
android:textColor="#fff"
android:nextFocusDown="#+id/pass" />
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/pass_container"
android:gravity="center"
android:layout_marginBottom="0.5dp"
android:layout_weight="1">
<ImageView
android:src="#drawable/passlogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/pass_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/pass"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#+id/pass_lable"
android:inputType="textPassword"
android:gravity="end"
android:hint="#string/password"
android:textColorHint="#d9e5f3"
android:textColor="#fff"
android:nextFocusDown="#+id/email"/>
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/email_container"
android:gravity="center"
android:layout_weight="1">
<ImageView
android:src="#drawable/maillogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/email_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/email"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:inputType="text"
android:layout_toLeftOf="#+id/email_lable"
android:hint="#string/email"
android:textColorHint="#d9e5f3"
android:textColor="#fff"
android:nextFocusDown="#+id/email"/>
</RelativeLayout>
<RelativeLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/phone_container"
android:gravity="center"
android:layout_weight="1">
<ImageView
android:src="#drawable/mobilelogo"
android:layout_width="22.0dp"
android:layout_height="22.0dp"
android:id="#+id/phone_lable"
android:tint="#d9e5f3"
android:layout_alignParentRight="true" />
<EditText
android:id="#+id/phone"
android:layout_width="197.0dp"
android:layout_height="35.5dp"
android:textSize="14dp"
android:layout_toLeftOf="#+id/phone_lable"
android:hint="#string/phone_num"
android:gravity="end"
android:inputType="phone"
android:textColorHint="#d9e5f3"
android:textColor="#fff" />
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/register_container"
android:gravity="center"
android:layout_weight="1">
<Button
android:text="Register"
android:layout_width="132.0dp"
android:layout_height="42.5dp"
android:id="#+id/register"
android:background="#drawable/loginbutton"
android:textColor="#color/black"
android:textStyle="bold"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
What can cause this?
tl;dr softKeyboard hides only 1 element out of five, and its the one with 'email' id.
So thanks to #Jay_Thummar I solved the problem.
wrapping the layout with ScrollView and changing the SoftInputMode to AdjustResize it worked.

On click of option scroll ListView to specific layout inside footerview

I have one Fragment in which I have one ListView and stick button at bottom.
The Listview has a fixed header and footer. In the footer view, when I choose one option one form will be visible. In that one expiry date Textview is there on that click one custom calendar expand and collapse. I want to scroll Listview till end of that calendar bottom but the problem is that I have set android:windowSoftInputMode="adjustPan" so that my stick button does not come up when soft keyboard is open. Because of this, I can't scroll Scrollview footerview form and can't scroll to bottom of calendar.
Can anyone help me? Thank you in advance.
Fragment 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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/application_background">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/card_list"
android:fadingEdgeLength="0dp"
android:scrollbars="none"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false"
android:transcriptMode="alwaysScroll" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:id="#+id/ll_footer"
android:gravity="center"
android:background="#color/colorIndicatorFill">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pay 250"
android:textColor="#color/white"
android:id="#+id/txt_pay"
android:gravity="center"
android:textSize="#dimen/fontsize_txtview_18" />
</LinearLayout>
</LinearLayout>
Footerview xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fillViewport="true"
android:isScrollContainer="false"
android:id="#+id/scrollView">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/ll_footer_card"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:id="#+id/rl_or">
<TextView
android:id="#+id/txt_or"
android:textSize="#dimen/fontsize_txtview_16"
android:singleLine="true"
android:text="#string/or"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="#color/colorActiveIndicator"/>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_1"
android:layout_centerVertical="true"
android:paddingLeft="#dimen/size_10"
android:layout_toLeftOf="#id/txt_or"
android:background="#color/gray_light" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_1"
android:layout_centerVertical="true"
android:paddingRight="#dimen/size_10"
android:layout_toRightOf="#id/txt_or"
android:background="#color/gray_light" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/ll_choose_other_card">
<TextView
android:layout_width="0dp"
android:layout_weight="0.9"
android:layout_height="wrap_content"
android:text="#string/choose_other_card"
android:id="#+id/txt_add_new_card"
android:textSize="#dimen/fontsize_txtview_16"
android:textColor="#color/colorActiveIndicator"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radio_add_new_crad"
style="#style/RadioButton" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/ll_card_detail_form">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<LinearLayout
android:layout_width="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/ll_scan_card"
android:layout_height="wrap_content"
android:background="#drawable/round_corner_light_green">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/cards"
android:id="#+id/iv_card"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/scan_card"
android:textSize="#dimen/fontsize_txtview_16"
android:textColor="#color/color_white"
android:id="#+id/txt_scan_card"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<View
android:layout_width="#dimen/size_300"
android:layout_gravity="center"
style="#style/DividerBottomLine"/>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_card_number"
android:hint="#string/hint_card_number"
android:singleLine="true"
android:digits=" 1234567890"
android:inputType="number"
android:maxLength="23"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:background="#drawable/edt_background" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_expiry"
android:hint="#string/hint_expiry"
android:singleLine="true"
android:inputType="none"
android:imeOptions="actionNext"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:background="#drawable/edt_background" />
<net.cachapa.expandablelayout.ExpandableLayout
android:id="#+id/expandable_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:el_duration="500"
app:el_expanded="false">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:id="#+id/ll_datePicker"
android:animateLayoutChanges="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/application_background"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/layout_choose"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<kankan.wheel.widget.WheelView
android:id="#+id/wheel_month"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#color/white"
android:layout_height="wrap_content" />
<kankan.wheel.widget.WheelView
android:id="#+id/wheel_year"
android:layout_width="0dp"
android:layout_weight="0.5"
android:background="#color/white"
android:layout_height="wrap_content" />
</LinearLayout>
<widget.RippleView
android:id="#+id/ripple_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
app:rv_centered="true"
app:rv_color="#color/white"
app:rv_type="simpleRipple" >
<TextView
android:id="#+id/txt_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#drawable/round_corner_light_green"
android:text="#string/btn_Done"
android:textColor="#color/color_white"
android:textSize="#dimen/fontsize_txtview_18" />
</widget.RippleView>
</LinearLayout>
</LinearLayout>
</net.cachapa.expandablelayout.ExpandableLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_cvv"
android:hint="#string/hint_cvv"
android:singleLine="true"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLength="4"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:background="#drawable/edt_background" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_name_on_card"
android:hint="#string/hint_name_on_card"
android:singleLine="true"
android:maxLength="100"
android:textColor="#color/text_color"
android:textColorHint="#color/hint_color"
android:textSize="#dimen/fontsize_edttext"
android:imeOptions="actionDone"
android:background="#drawable/edt_background" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/chk_save_card"
android:textColor="#color/text_color"
style="#style/Checkbox"
android:textSize="#dimen/fontsize_edttext"
android:text="#string/save_card" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/size_10"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

Stack two vertical LinearLayout in LinearLayout horizontally

I'm trying to stack two vertical LinearLayout in LinearLayout horizontally.
My code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horisontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Also everything looks as I and has conceived:
And the scheme for full understanding:
But when I compile that in VS2015 see error "String types not allowed (at 'orientation' with value 'horisontal')". Need help
Its a typo.
Change,
android:orientation="horisontal"
to
android:orientation="horizontal"
In the root use below attribute
wheightSum="10"
and in child view use wheight = "5" for each child view
Note: on base layout use android:orientation="horizontal" for horizontal display or android:orientation="vertical" for vertical display
Error in LinearLayout orientation.It should be horizontal or remove this.(By default Linear layout has horizontal orientation. )
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:text="User Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtusername" />
<TextView
android:text="Date registration"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtdateregistr" />
<TextView
android:text="Phone number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/txtphonenumb" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercountnumb" />
<TextView
android:text="Ordr"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/ordercount" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/linearLayout1">
<TextView
android:text="Count"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycountnumb" />
<TextView
android:text="Delv"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/deliverycount" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

Linear layout below the ListView, Some portions not visible?

I have a problem with LinearLayout which is below the listview. I tried to give the listview weight and layout above, set the layout_height to 0dp but nothing wotked.
Here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
when ListView fills the screen, I cannot see the buttons below to it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30" />
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="90">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Your layout edited by adding layout weights. Please check.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="0.3"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
You should try List View with Layout having weight.
Sample Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
/>
</LinearLayout>
In this your height is fixed for listview. Assuming that you can use list view as srollable in particular height.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/topLayout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alignParentTop="true"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:alignParentBottom="true"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/topLayout"
android:layout_above="#+id/bottomLayout">
</ListView>
</RelativeLayout>
Have edited your code. Try this.
Here in this I have used RelativeLayout, so that we use android:alignParentBottom="true" for bottom layout which makes the layout in fix in bottom. Simillarly we can do for top layout using android:alignParentBottom="true". Now coming to ListView, which we need to place between top and bottom layout I have used the following code to achieve it
android:layout_below="#+id/topLayout"
android:layout_above="#+id/bottomLayout"
This makes the ListView to stick in between the top and bottom layout.
Hope this is helpful:)
Change as below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Categories

Resources