Table layout overlaps Linear Layout in Android studio - android

I am having issue aligning my contents in a proper order. When I test my app in emulator, I discovered table layout overlapping the Linear layout. I have tried some solutions but none worked.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#drawable/table_background2" android:layout_width="match_parent" android:layout_height="match_parent">
<RelativeLayout android:gravity="center" android:id="#+id/headerpicture" android:background="#color/loginheader" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true">
<TextView android:textSize="20sp" android:textColor="#fff" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="#string/fixed_header"/>
<ImageView android:id="#+id/imgLeftBack" android:layout_width="35dp" android:layout_height="35dp" android:src="#drawable/arrow_left_green" android:layout_alignParentRight="true" android:onClick="goBack" android:contentDescription="#string/empty"/>
</RelativeLayout>
<RelativeLayout android:gravity="center" android:id="#+id/footer" android:background="#color/loginheader" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true">
<TextView android:textColor="#fff" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:text="#string/copyright" android:ems="8"/>
</RelativeLayout>
<TableLayout android:layout_gravity="top" android:id="#+id/tableLayout1" android:background="#drawable/gradient" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginTop="5dp" android:layout_marginRight="5dp" android:layout_below="#+id/headerpicture">
<TableRow android:id="#+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:textColor="#color/list_item_text" android:ellipsize="none" android:layout_gravity="top" android:id="#+id/textViewUsernamePicture" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="#dimen/text_view_marginLeft" android:layout_marginTop="#dimen/text_view_marginTop" android:text="#string/pre_election_usernameLbl" android:layout_weight="1"/>
<EditText android:layout_gravity="left|center_vertical|center_horizontal|center" android:id="#+id/txtUsernamePicture" android:layout_width="wrap_content" android:layout_height="#dimen/edit_text_height" android:layout_marginLeft="#dimen/text_view_marginLeft" android:ems="8" android:layout_weight="3" android:inputType="text"/>
</TableRow>
<TableRow android:layout_marginBottom="10dp" android:id="#+id/tableLayout2Row9" android:layout_width="wrap_content" android:layout_height="wrap_content">
<EditText android:gravity="top|left|center_vertical|center_horizontal|center" android:layout_gravity="left|center_vertical|center_horizontal|center" android:id="#+id/txtTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="3" android:inputType="text" android:hint="Incident Title" android:layout_marginLeft="#dimen/table_marginLeft"/>
</TableRow>
</TableLayout>
<ImageView android:layout_marginBottom="0dp" android:layout_gravity="center" android:id="#+id/ImgPicture" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="#dimen/text_view_marginTop" android:src="#drawable/picture_placeholder" android:layout_below="#+id/tableLayout1" android:contentDescription="#string/empty"/>
<TableLayout android:layout_gravity="top" android:id="#+id/tableLayout2" android:background="#drawable/gradient" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginTop="5dp" android:layout_marginRight="5dp" android:layout_below="#+id/ImgPicture">
<TableRow android:layout_marginBottom="10dp" android:id="#+id/tableLayout2Row13" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:textColor="#color/list_item_text" android:ellipsize="none" android:layout_gravity="top" android:id="#+id/textViewPriorityIncident" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="#dimen/text_view_marginLeft" android:layout_marginTop="#dimen/text_view_marginTop" android:text="#string/incident_priorityLbl" android:layout_weight="1"/>
<Spinner android:entries="#array/incident_priority_arrays" android:id="#+id/spinnerPriorityIncident" android:layout_width="match_parent" android:layout_height="wrap_content" android:prompt="#string/incident_priority_prompt"/>
</TableRow>
<TableRow android:layout_marginBottom="10dp" android:id="#+id/tableLayout2Row5" android:layout_width="wrap_content" android:layout_height="wrap_content">
<EditText android:gravity="top|left|center_vertical|center_horizontal|center" android:layout_gravity="left|center_vertical|center_horizontal|center" android:id="#+id/txtCommentsIncident" android:scrollbars="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="#dimen/table_marginLeft" android:lines="4" android:minLines="3" android:ems="8" android:maxLength="#string/comments_length" android:layout_weight="3" android:inputType="textMultiLine" android:hint="Comment"/>
</TableRow>
</TableLayout>
<LinearLayout android:id="#+id/btnsHolder" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="#+id/tableLayout2" android:layout_above="#id/footer">
<Button android:background="#color/red" android:textColor="#color/redtextxolor" android:tint="#color/redtextxolor" android:id="#+id/btnSaveImage" android:paddingLeft="#dimen/btn_padding_left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:text="#string/btnBack" android:drawableLeft="#android:drawable/ic_media_previous" android:onClick="goBack"/>
<Button android:background="#color/btn" android:textColor="#color/btntextcolor" android:tint="#color/btntextcolor" android:layout_gravity="center" android:id="#+id/btnTakePicture" android:paddingLeft="10sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:text="#string/btnSnap" android:drawableLeft="#android:drawable/ic_menu_camera" android:onClick="captureImage"/>
<Button android:background="#color/snap" android:textColor="#color/white" android:tint="#color/white" android:layout_gravity="center" android:id="#+id/btnSendPicture" android:paddingLeft="10sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:text="#string/btnSendSnap" android:drawableLeft="#android:drawable/ic_menu_send" android:onClick="sendForm"/>
</LinearLayout>
</RelativeLayout>

First off that is the worst formatting I have ever seen lol buuut inside the linear layout just set it to be under the table layout
like this
<TableLayout
android:id="#+id/mytable"
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableLayout>
<LinearLayout
android:id="#+id/mylinear"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/mytable">
</LinearLayout>
notice the android:layout_below="#+id/mytable"> . which is the id i gave to the table view just do that then they shouldnt overlap, now in your code this would mean you're going to have to give an id to the table layout in order to do this
dont mind the height and width I gave the linear view all you should worry about if the layout_below the rest was just me hitting enter to fill

<LinearLayout
android:orientation="horizontal"
android:background="#drawable/gradient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp" >
<Spinner
android:entries="#array/incident_priority_arrays"
android:id="#+id/spinnerPriorityIncident"
android:layout_width="wrap_content"\
android:layout_height="wrap_content"
android:layout_gravity="center"
android:prompt="#string/incident_priority_prompt"/>
<TextView
android:textColor="#color/list_item_text"
android:ellipsize="none"
android:id="#+id/textViewPriorityIncident"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/text_view_marginLeft"
android:layout_marginTop="#dimen/text_view_marginTop"
android:text="#string/incident_priorityLbl" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:gravity="center"
android:id="#+id/txtCommentsIncident"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/table_marginLeft"
android:lines="4"
android:minLines="3"
android:ems="8"
android:maxLength="#string/comments_length"
android:inputType="textMultiLine"
android:hint="Comment"/>
</LinearLayout>
<LinearLayout android:id="#+id/btnsHolder"
android:layout_gravity="center"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tableLayout2"
android:layout_above="#id/footer">
<Button
android:background="#color/red"
android:textColor="#color/redtextxolor"
android:tint="#color/redtextxolor"
android:id="#+id/btnSaveImage"
android:paddingLeft="#dimen/btn_padding_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/btnBack"
android:drawableLeft="#android:drawable/ic_media_previous"
android:onClick="goBack"/>
<Button
android:background="#color/btn"
android:textColor="#color/btntextcolor"
android:tint="#color/btntextcolor"
android:layout_gravity="center"
android:id="#+id/btnTakePicture"
android:paddingLeft="10sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/btnSnap"
android:drawableLeft="#android:drawable/ic_menu_camera"
android:onClick="captureImage"/>
<Button
android:background="#color/snap"
android:textColor="#color/white"
android:tint="#color/white"
android:layout_gravity="center"
android:id="#+id/btnSendPicture"
android:paddingLeft="10sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/btnSendSnap"
android:drawableLeft="#android:drawable/ic_menu_send"
android:onClick="sendForm"/>
</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>

ScrollView Not Working(It's Not Scrolling the layout)

I am new to Android and working on a App and stuck here on ScrollView. I have tried width and height "match parent" but still not working. I am posting my code. I have wasted more than an hour on this. Thanks in advance.
Here is my XML:
<?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:weightSum="1"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.02"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"
android:text="Marketing"
android:textColor="#color/black"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_header"
android:layout_weight="0.02"
android:background="#color/light_blue"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Register Here"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="0.04"
android:orientation="vertical">
<EditText
android:id="#+id/edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name*"
android:inputType="text" />
<EditText
android:id="#+id/edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Email*"
android:inputType="text" />
<EditText
android:id="#+id/edit_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password*"
android:inputType="text" />
<EditText
android:id="#+id/edit_cnfrm_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Confirm Password*"
android:inputType="text" />
<Button
android:id="#+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_bg"
android:padding="15dp"
android:text="Register"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_forgot_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Forgot/Reset Password"
android:textColor="#color/light_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:weightSum="1"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GOOGLE"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="15sp"
android:layout_marginRight="5dp"
android:background="#color/red"
android:layout_weight="0.5"/>
<Button
android:id="#+id/btn_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FACEBOOK"
android:textColor="#color/white"
android:background="#color/fb_blue"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textSize="15sp"
android:layout_weight="0.5"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
set lay out weight to scroll view like
<ScrollView
android:layout_weight="0.96"
android:layout_width="match_parent"
android:layout_height="wrap_content">

scrollable layout not working

I'm a beginner in android. I'm creating a example phonebook using eclipse. i have few edit texts and a set off buttons in my layout.but when I run the project I can't see the buttons in the bottom of the layout, so I enclosed my main linear layout in a Scrollview. but after linear layout has become much bigger in height. i tried to resize it in the xml file but it is not working right after resizing the layout it automatically resizes in to the previous size. here's my code if anyone can help me.little help is highly appreciated.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="466dp"
android:layout_gravity="center_vertical" >
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
tools:context="com.nadusha.phonebook.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact Info"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/nameTextLayout"
android:orientation="horizontal"
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/nameTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<requestFocus />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"/>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/mobileNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/homeNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-Mail "
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/emailTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/saveBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:textColor="#FFFFFF"/>
<Button
android:id="#+id/cancelBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/viewBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ViewContact"
android:textColor="#FFFFFF" />
</Linearlayout>
</LinearLayout>
You need to set ScrollView layoutWeight to 1 and its height to 0. This will ensure that your scrollview will take only remaining space on screen. Here is example of my app:
<?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:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:clickable="false"
android:fadeScrollbars="false"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/menoLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSMeno"/>
<EditText
android:id="#+id/menoEdit"
style="#style/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName"
android:textColor="#000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="3">
<TextView
android:id="#+id/pohlavieLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSPohlavie"/>
<Spinner
android:id="#+id/spinnerPohlavie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/vekLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSVek"/>
<EditText
android:id="#+id/vekEdit"
style="#style/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="numberDecimal"
android:textColor="#000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="#+id/vahaLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="#string/emergencySMSVaha"/>
<EditText
android:id="#+id/vahaEdit"
style="#style/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="numberDecimal"
android:textColor="#000"/>
</LinearLayout>
<TextView
android:id="#+id/alergieLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSAlergie"/>
<EditText
android:id="#+id/alergieEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textColor="#000"/>
<TextView
android:id="#+id/chorobyLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSChoroby"/>
<EditText
android:id="#+id/chorobyEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textColor="#000"/>
<TextView
android:id="#+id/zraneniaLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSZranenie"/>
<EditText
android:id="#+id/zraneniaEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine"
android:lines="3"
android:textColor="#000"/>
<TextView
android:id="#+id/polohaLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:padding="5dp"
android:text="#string/emergencySMSAktualnaPoloha"/>
<EditText
android:id="#+id/polohaEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:textColor="#000"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp">
<Button
android:id="#+id/odoslatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/send"
android:layout_weight="1"/>
<Button
android:id="#+id/zrusitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/emergencySMSZrusit"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
It shows scrollView and two buttons bellow it. I am not exactly sure what you want to do but as far as I can see you are doint it wrong. ScrollView can take only one child element but you have set scrollview as your main parent but then you put more child inside it.
Also you are doing another mistake. You dont need to use linear layouts (in most cases) if they have only one child. It is bad for performance.
Change the value of the attribute layout_height to match_parent so that the ScrollView take up the whole screen and hence enable scrolling. The correct code is
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical" >
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
tools:context="com.nadusha.phonebook.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginBottom="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact Info"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:id="#+id/nameTextLayout"
android:orientation="horizontal"
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/nameTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
<requestFocus />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF"/>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/mobileNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/homeNoTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-Mail "
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_marginBottom="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/emailTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/saveBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:textColor="#FFFFFF"/>
<Button
android:id="#+id/cancelBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/viewBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ViewContact"
android:textColor="#FFFFFF" />
</Linearlayout>
</LinearLayout>
You could try changing
android:layout_height="466dp"
to
android:layout_height="wrap_content"
or
android:layout_height="match_parent"

How to position a login box centered on application start?

I am new to Android and trying to build a login box, and experience some troubles. I created two textes (Username, Password) and two text-boxes next to them, to style a login box area.
But unfortunately the elements jump up and down in correlation with the upper and lower bars, that are shown when the user touches the screen.
How can I realize a centered login box?
Link: maximize image
Here is some code:
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout android:id="#+id/fullscreen_content_controls"
style="?buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="#color/black_overlay"
android:orientation="horizontal"
tools:ignore="UselessParent">
<Button android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/login_button" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical|center_horizontal">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:baselineAligned="false"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:layout_alignParentBottom="false"
android:layout_centerInParent="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_username"
android:id="#+id/textView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_column="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_password"
android:id="#+id/textView2"
android:layout_column="0" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:layout_column="1" />
</TableRow>
</TableLayout>
</RelativeLayout>
</FrameLayout>
There is no need of Table Layout It simply done with relative and linearlayout.
http://www.androidhive.info/2011/10/android-login-and-registration-screen-design/
Use this -
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_username"
android:id="#+id/textView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_column="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_password"
android:id="#+id/textView2"
android:layout_column="0" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText2"
android:layout_column="1" />
</TableRow>
</TableLayout>
</RelativeLayout>
<Button
android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom"
android:text="#string/login_button" />
</FrameLayout>
// try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:gravity="center"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:padding="10dp"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_username"
android:id="#+id/textView" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:id="#+id/editText"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_password"
android:id="#+id/textView2"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textPassword"
android:ems="10"
android:layout_marginLeft="5dp"
android:id="#+id/editText3"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="#+id/fullscreen_content_controls"
style="?buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#color/black_overlay">
<Button android:id="#+id/dummy_button"
style="?buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login_button" />
</LinearLayout>
</LinearLayout>

How to include blank view in Layout

i design a login view. I want to insert a fragment layout which is placed at the center of parent view. I hard code to input some fragment layout to make this effect. But, does there exist better way to do this.
This is my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="2"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1">
</FrameLayout>
<FrameLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="2">
</FrameLayout>
<FrameLayout
android:id="#+id/login_frame"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1">
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
</FrameLayout>
</LinearLayout>
Thanks you.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical">
<TableRow
android:id="#+id/row1"
android:layout_marginTop="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txtUserName"
android:layout_marginLeft="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="Username"
android:textSize="16sp" />
</TableRow>
<TableRow
android:id="#+id/row2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:inputType="text"
android:id="#+id/editUsername"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_weight="2"
android:singleLine="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="2dip"
android:layout_marginRight="50dp"
android:padding="10dp"/>
</TableRow>
<TableRow
android:id="#+id/row3"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:layout_marginLeft="50dp"
android:text="password"
android:textSize="16sp" />
</TableRow>
<TableRow
android:id="#+id/row4"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:inputType="textPassword"
android:id="#+id/editPassword"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_weight="2"
android:layout_marginTop="2dip"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:padding="10dp"
android:password="true"
android:singleLine="true"/>
</TableRow>
<TableRow
android:id="#+id/row5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<CheckBox
android:id="#+id/chkRememberPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="52dp"
android:padding="10dp"
android:textSize="15sp"
android:text="rememberme"
/>
</TableRow>
<TableRow
android:id="#+id/row6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/login"
android:layout_width="100dp"
android:layout_height="35dp"
android:text="login"
android:textStyle="bold"
android:layout_marginLeft="102dp"/>
</TableRow>

Categories

Resources