Linear layout inside Lineary layout in android - android

I am trying to create a layout in android, when i create a linear layout inside a linear layout its getting added but not visible in the interface. here is my code
<?xml version="1.0" encoding="utf-8"?>
<!-- Parent linear layout with vertical orientation -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="_baseline"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="#string/name" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="0dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="290dp"
android:text="#string/submit" />
<!-- Child linear layout with horizontal orientation -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2a2a2a"
android:baselineAligned="_baseline"
android:orientation="horizontal" >
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Previous" android:padding="15dip" android:layout_weight="1"
android:gravity="center"/>
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Next" android:padding="15dip" android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>

Try this I think you want this type of UI.
<?xml version="1.0" encoding="utf-8"?>
<!-- Parent linear layout with vertical orientation -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="#string/app_name" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="0dp"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="290dp"
/>
<!-- Child linear layout with horizontal orientation -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2a2a2a"
android:orientation="horizontal" >
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Previous" android:padding="15dip" android:layout_weight="1"
android:gravity="center"/>
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Next" android:padding="15dip" android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
the prob. is that you want to TextView and EditText in single line for that you put parent LinearLayout in Horizontal orientation but because of that all content saperated in gorizontalway..
so, you need to parent Layout Orientation as Vertical and take new Layout in that for EditText and TextView for horizontal separation. and that new Layout you need in Horizontal Orientation.
Show your UI here:

Change the first Linear Layout orientation "vertical". It should be works..

Your parent layout is showing the child layout, but it is out of view. Change the Parent's layout orientation to Vertical and it will be visible.
Make these changes..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="_baseline"
android:orientation="vertical" >
To get edittext in the same line,
Create a child layout for textview and edittext and make its orientation as horizontal.. it will be in the same line
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="_baseline"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="_baseline"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="#string/name" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="0dp"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
...
...
</LinearLayout>

This is your description as you posted question, You done mistake in orientation, In Comment you write
< !-- Parent linear layout with vertical orientation -->
but in LinearLayout you set Orientation
android:orientation="horizontal"
make it to
android:orientation="vertical"
and your problem is solved.

try this...
<?xml version="1.0" encoding="utf-8"?>
<!-- Parent linear layout with vertical orientation -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="_baseline"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="#string/name" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="0dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="290dp"
android:text="#string/submit" />
</LinearLayout>
<!-- Child linear layout with horizontal orientation -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2a2a2a"
android:layout_weight="1"
android:baselineAligned="_baseline"
android:orientation="horizontal" >
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Previous" android:padding="15dip" android:layout_weight="1"
android:gravity="center"/>
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Next" android:padding="15dip" android:layout_weight="1"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>

Related

Set textview below another textview in horizontal linear layout

How to set TextView object tvOperationDesc below tvOperationName
This is my layout xml:
<?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"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvOperationName"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center_vertical"
/>
<TextView
android:id="#+id/tvOperationDesc"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:layout_below="#+id/tvOperationName"
/>
<EditText
android:id="#+id/txtMultiplier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:inputType="numberDecimal"
android:text="0"
android:textAppearance="?android:attr/textAppearanceSmall" />
<CheckBox
android:id="#+id/cbChkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
Use 2 separate horizontal linear layouts in your relative layout and you can adjust the weights and the heights as you like:
<?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"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin">
<LinearLayout
android:id="#+id/upLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<TextView
android:id="#+id/tvOperationName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2" />
<EditText
android:id="#+id/txtMultiplier"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:inputType="numberDecimal"
android:text="0"
android:textAppearance="?android:attr/textAppearanceSmall" />
<CheckBox
android:id="#+id/cbChkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/upLayout">
<TextView
android:id="#+id/tvOperationDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"/>
</LinearLayout>
</RelativeLayout>
Textview below textview in horizontal linear layout
Not possible at all. Its clearly mentioned horizontal linear layout. So, you views are aligned horizontally only.
Then
If you set your linear layout orientation to horizontal your views are aligned horizontally & orientation to vertical your views are aligned vertically in linear manner that means one by one.
Solution
One relative layout is enough for your requirements. Have a look at my answer How relative layout views are aligned will help you.
Please try below code.
<TextView
android:id="#+id/tvOperationDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Description" />
<LinearLayout
android:id="#+id/secondLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/tvOperationName"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:text="Name" />
<EditText
android:id="#+id/txtMultiplier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:inputType="numberDecimal"
android:text="0"
android:textAppearance="?android:attr/textAppearanceSmall" />
<CheckBox
android:id="#+id/cbChkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
if you want EditText and Checkbox in the same line as tvOperationName vertically just change orientation of secondLinearLayout to vertical and give gravity="center_horizontal" to secondLinearLayout.
Add another LinearLayout with orientation to vertical, and place both the TextView.
And remove layout_below property inside LinearLayout’s child view, as its useless.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tvOperationName"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center_vertical"
/>
<TextView
android:id="#+id/tvOperationDesc"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center_vertical"
android:layout_below="#+id/tvOperationName"
/>
</LinearLayout>

Keyboard overlaps Edit Text

Hello i have an activity which contains the following elements
this is my xml layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#dddddd">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#dddddd">
<TextView android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="title"
android:textSize="#dimen/checkout_title"
android:textColor="#858585"
android:textStyle="bold"
android:layout_margin="10dp" />
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="474dp"
android:layout_below="#+id/title"
android:layout_marginBottom="10dp"></android.support.v4.view.ViewPager>
<com.pockee.views.CirclePageIndicator android:id="#+id/indicator"
android:padding="0dp"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="#+id/pager"
app:pageColor="#858585"
app:fillColor="#f19201" />
<LinearLayout android:layout_below="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip"
android:background="#80000000"
android:layout_margin="10dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Value:"
android:textColor="#color/white" />
<EditText
android:id="#+id/value1"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="#color/white"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:inputType="number" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dip"
android:text="Value2:"
android:textColor="#color/white" />
<EditText
android:id="#+id/value2"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:password="true"
android:background="#color/white"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:inputType="number" />
<Button
android:id="#+id/btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:text="OK"
android:background="#f19100"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
in my manifest i'm using
android:windowSoftInputMode="adjustResize|stateVisible"
the problem is that the number keyboard overlaps edit text by 10 pixels
any ideas on this issue?
I see you have a relative layout wrapping your linear layout, yet both your linearLayout and relative layout have a margin of 10dp. Try editing the inner value 'LinearLayout' margin to 0 or changing margin altogether i.e use bottom-margin:0 instead of margin and reloading.

ViewPager/Fragment overlapping LinearLayout at bottom

I have a ViewPager which shows Fragments and I want that on the top, and a simple LinearLayout on the bottom. But, the Fragments are overlapping the layout at the bottom. I want the Fragment to end right about the LinearLayout. See picture:
XML with ViewPager
<?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" >
<android.support.v4.view.ViewPager
android:id="#+id/steps_pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/finish_checklist_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_white_glossy"
android:layout_margin="20dp"
android:text="#string/finish_checklist" />
</LinearLayout>
XML of Fragment
<?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"
android:padding="20dp"
android:background="#fff" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="26sp"
android:text="#string/step_order_label" />
<TextView
android:id="#+id/step_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="26sp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#000" />
<TextView
android:id="#+id/step_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="26sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="40dp"
android:textSize="20sp"
android:text="#string/result_label" />
<TextView
android:id="#+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" />
</LinearLayout>
<!-- YES/NO BUTTONS -->
<Button
android:id="#+id/button_no"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/btn_white_glossy"
android:padding="20dp"
android:visibility="gone"
android:text="#string/button_no" />
<Button
android:id="#+id/button_yes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/button_no"
android:background="#drawable/btn_white_glossy"
android:padding="20dp"
android:layout_marginBottom="30dp"
android:visibility="gone"
android:text="#string/button_yes" />
<!-- END YES/NO BUTTONS -->
I used android:layout_below element here.
layout_below your ViewPager id.
and this layout as vertical
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="fill_vertical"
android:orientation="vertical" >
In all your xml files, should define the background color for it, it will solve the problem :
Add this android:background="#android:color/black" in to the View tag you defined.
p/s : This case only avoid Background was overlapped.

how to set a button at the bottom of a screen when the parent is a scroll view?

I have a scrollView (this is a solution to support landscape computability)
and in it one child- linearLayout.
I want to pose a button at the bottom of a screen.
layout_height = match_parent is problematic as the scroll can be infinite.
How can I do this, to be compatible to all screen resolution?
this is my xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.m"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blue_bg" >
<LinearLayout
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<com.m.view.text.mTextView
android:id="#+id/verifyHeaderText"
style="#style/textOnBg"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="50dp"
android:text="ENTER VERIFICATION CODE"
android:textAllCaps="true"
android:textColor="#android:color/white"
app:font_type="varela" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:paddingBottom="5dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="5dp" >
<LinearLayout
android:id="#+id/inputBox"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:background="#drawable/input_box_idle"
android:orientation="horizontal" >
<EditText
android:id="#+id/verificationCodeEditText"
style="#style/textOnBg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="- - - - -"
android:inputType="number"
android:maxLength="5"
android:textColor="#00bcfe"
android:textSize="25dp"
android:textStyle="italic" >
</EditText>
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/continueButton"
style="#style/textOnBg"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="#drawable/btn_selector"
android:text="Continue"
android:textColor="#00bcfe"
android:textSize="16dp"
android:textStyle="italic" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
this is the result on wide-screen
The button is in the bottom of the scroll which spans 3/4 of the whole screen
Add android:fillViewport="true" to your scrollview:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.m"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blue_bg"
android:fillViewport="true" >
Apply this to your layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Your scroll view -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_marginBottom="#dimen/ar_button_height"
android:gravity="center" >
<Button
android:id="#+id/button_at_bottom"
android:layout_width="match_parent"
android:layout_height="#dimen/ar_button_height"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal"
android:showDividers="middle" >
</Button>
</ScrollView>
</RelativeLayout>
Not sure if there is a better solution, but you could put your scroll view inside a relative layout and have your button outside the scroll view and set android:layout_alignParentBottom="true" on the button
If you want to set the button at the bottom you need to implement your layout with weight.
First of all the scrollview can only have one child layout inside it.
Secondly add your content layout inside the child layout of it, set the layout_height to 0dp, and do remember to set the weight to 1.
And at last add your button at the bottom of your content layout and set its height and set the weight to be 0.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollMain"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="always"
android:background="#00000000"
android:scrollbars="none">
<LinearLayout
android:overScrollMode="always"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:background="#FFFFFF"
android:paddingTop="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</LinearLayout>
<Button android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_weight="0" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
<com.m.view.text.mTextView
android:id="#+id/verifyHeaderText"
style="#style/textOnBg"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="50dp"
android:text="ENTER VERIFICATION CODE"
android:textAllCaps="true"
android:textColor="#android:color/white"
app:font_type="varela" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:paddingBottom="5dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="5dp" >
<LinearLayout
android:id="#+id/inputBox"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:background="#drawable/input_box_idle"
android:orientation="horizontal" >
<EditText
android:id="#+id/verificationCodeEditText"
style="#style/textOnBg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="- - - - -"
android:inputType="number"
android:maxLength="5"
android:textColor="#00bcfe"
android:textSize="25dp"
android:textStyle="italic" >
</EditText>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<Button
android:id="#+id/continueButton"
style="#style/textOnBg"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="#drawable/btn_selector"
android:text="Continue"
android:textColor="#00bcfe"
android:textSize="16dp"
android:textStyle="italic" />
USe your button here
You can use scrollView inside relativeLayout to fix your button at bottom:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/radialback">
<ScrollView android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="#+id/top_header"
>
<EditText
android:id="#+id/editmessage"
android:layout_margin="2dp"
style="#style/editView"
android:inputType="textMultiLine"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 _-.,()"
android:maxLength="500"
/>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/submitbutton"
android:text="#string/submitbutton"
style="#style/submitView"
android:layout_alignParentBottom="true" />
</RelativeLayout>

android layout doesn't apprea

i have two layouts vertically , first one has edittext and button, second one has two listvies ,
the first one doesn't appear, and i got an exception when running the application
<?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"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/etRestaurantSearchName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Enter name"
android:inputType="text"
android:textSize="15dip" />
<Button
android:id="#+id/bRestaurantSearchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Search" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ListView
android:id="#+id/lvRestaurants"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffffff"
android:fillViewport="true" >
</ListView>
<ListView
android:id="#+id/lvAlphabets"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="#drawable/foods_alphabets_bg"
android:orientation="vertical" >
</ListView>
</LinearLayout>
</RelativeLayout>
i ma sure it is something about hiegh , width or weight,
You have used RelativeLayout as the parent layout for the inner two layouts. Therefore the second inner Linear Layout overlaps the first one , thus first one cant be seen. Make use of linear layout as parent layout
Try this:
Correction :
android:layout_below="#+id/Layout1" for layout two.
and some weight related changes.
<LinearLayout
android:id="#+id/Layout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/etRestaurantSearchName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Enter name"
android:inputType="text"
android:textSize="15dip" />
<Button
android:id="#+id/bRestaurantSearchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Search" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Layout1"
android:orientation="horizontal" >
<ListView
android:id="#+id/lvRestaurants"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/edit_text"
android:fillViewport="true" >
</ListView>
<ListView
android:id="#+id/lvAlphabets"
android:layout_width="40dp"
android:layout_height="match_parent"
android:background="#drawable/btn_bg_pressed"
android:orientation="vertical" >
</ListView>
</LinearLayout>

Categories

Resources