Android: EditText pushes the layout to the top - android

I have a edit text in the bottom of my activity and when user click on the edit box it pushes the buttons and lables above it to futher top. How can I avoid this? when user clicks and types on the edit text it should not push the layout up.
<EditText android:gravity="top|left" android:hint="#string/description"
android:id="#+id/editText1des" android:layout_below="#+id/buildbtn" android:layout_alignLeft="#+id/buildbtn"
android:layout_alignRight="#+id/buildbtn" android:layout_marginTop="30dp" android:layout_height="fill_parent" android:layout_width="fill_parent"
android:inputType="textFilter|textMultiLine|textNoSuggestions" android:scrollHorizontally="true"></EditText>
Can someone please help me thanks.
full layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:id="#+id/homepgeaudiobtn"
android:background="#E6E7E2">
<RelativeLayout android:weightSum="1.0"
android:layout_width="fill_parent" android:layout_alignParentBottom="true"
android:background="#cf1616" android:layout_height="50dp">
<Button android:layout_alignParentRight="true"
android:background="#drawable/butonn" android:layout_height="30dp"
android:layout_width="90dp" android:textColor="#FFF" android:text="#string/btnSubmitString" android:id="#+id/sendincidentbtn" android:layout_margin="10dp"/>
<TextView android:id="#+id/textView1"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="RDMS" android:textColor="#FFF" android:textStyle="bold" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:textSize="35dp"></TextView>
<Button android:textColor="#FFF" android:layout_height="30dp" android:layout_width="90dp" android:layout_alignParentLeft="true" android:id="#+id/backid" android:background="#drawable/back_button" android:text="#string/gobackString" android:layout_margin="10dp"></Button>
</RelativeLayout>
<LinearLayout android:weightSum="1.0"
android:layout_width="fill_parent" android:layout_marginBottom="20dp"
android:background="#FFF" android:layout_height="65dp">
<Button android:id="#+id/allimagebtn" android:layout_weight=".30"
android:textColor="#FFF"
android:background="#drawable/cam_red" android:text="Images" android:paddingLeft="10dp" android:layout_marginTop="2dp" android:paddingTop="2dp" android:layout_width="100dp" android:layout_margin="2dp" android:layout_height="fill_parent" android:gravity="bottom"/>
<Button android:id="#+id/button2video" android:layout_weight=".30"
android:background="#drawable/vid_red" android:textColor="#FFF" android:text="Video Files" android:gravity="bottom" android:textSize="12dp" android:paddingLeft="10dp" android:paddingTop="2dp" android:layout_width="100dp" android:layout_marginTop="2dp" android:layout_height="fill_parent" android:layout_marginBottom="2dp"/>
<Button android:id="#+id/button3audio" android:layout_weight=".30"
android:textColor="#FFF"
android:background="#drawable/aud_red" android:text="Audio Files" android:gravity="bottom" android:textSize="12dp" android:paddingLeft="10dp" android:paddingTop="2dp" android:layout_marginTop="2dp" android:layout_width="100dp" android:layout_margin="2dp" android:layout_height="fill_parent"/>
</LinearLayout>
<LinearLayout android:layout_height="0px"
android:layout_width="0px" android:id="#+id/linearLayout2993"
android:focusable="true" android:focusableInTouchMode="true"></LinearLayout>
<TextView android:id="#+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000" android:textSize="20dp" android:textStyle="bold" android:text="Ipsum Lorem" android:paddingLeft="20dp"></TextView>
<RelativeLayout android:layout_width="fill_parent"
android:id="#+id/relativeLayout4" android:layout_height="fill_parent">
<TextView android:layout_height="0dp" android:text="TextView"
android:id="#+id/allincidentimagecount" android:layout_width="0dp"
android:layout_below="#+id/allimagebtn" android:layout_alignLeft="#+id/allimagebtn"
android:layout_alignRight="#+id/allimagebtn"></TextView>
<Button android:layout_below="#+id/allincidentimagecount"
android:layout_alignLeft="#+id/allincidentimagecount"
android:layout_width="fill_parent" android:text="#string/type"
android:id="#+id/typebtn" android:layout_marginTop="5sp" android:background="#drawable/tab_top" android:layout_height="40dp" android:gravity="left|fill_vertical" android:paddingLeft="10dp" android:textSize="20dp"></Button>
<Button android:text="#string/location"
android:layout_width="wrap_content" android:layout_below="#+id/typebtn"
android:layout_alignLeft="#+id/typebtn" android:layout_alignRight="#+id/typebtn"
android:id="#+id/locbtn" android:background="#drawable/tab_middle" android:layout_height="32dp" android:paddingLeft="10dp" android:gravity="left|fill_vertical" android:textSize="20dp"></Button>
<Button android:text="#string/building"
android:layout_width="wrap_content" android:layout_below="#+id/locbtn"
android:layout_alignLeft="#+id/locbtn" android:layout_alignRight="#+id/locbtn"
android:id="#+id/buildbtn" android:background="#drawable/tab_bottom" android:layout_height="43dp" android:paddingLeft="10dp" android:gravity="left|fill_vertical" android:textSize="20dp"></Button>
<EditText android:gravity="top|left" android:hint="#string/description"
android:id="#+id/editText1des" android:layout_below="#+id/buildbtn" android:layout_alignLeft="#+id/buildbtn"
android:layout_alignRight="#+id/buildbtn" android:layout_marginTop="30dp" android:inputType="textFilter|textMultiLine|textNoSuggestions" android:scrollHorizontally="true" android:layout_height="wrap_content" android:layout_width="wrap_content"></EditText>
<TextView android:layout_height="0dp" android:text="TextView"
android:layout_width="0dp" android:layout_below="#+id/button2video"
android:layout_alignLeft="#+id/button2video"
android:layout_alignRight="#+id/button2video" android:id="#+id/videovounttxt99"></TextView>
<TextView android:id="#+id/audiocounttxtx"
android:layout_height="0dp" android:text="TextView"
android:layout_width="0dp" android:layout_below="#+id/button3audio"
android:layout_alignLeft="#+id/button3audio"
android:layout_alignRight="#+id/button3audio"></TextView>
</RelativeLayout>
<RelativeLayout android:id="#+id/layout02"
android:paddingTop="30dp" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_width="fill_parent"
android:background="#000" android:gravity="center"></TextView>
</RelativeLayout>
</LinearLayout>

I notice that you have used the same button id for the three attributes namely
android:layout_below="#+id/buildbtn" android:layout_alignLeft="#+id/buildbtn"
android:layout_alignRight="#+id/buildbtn"
wherein lies your problem.

It's because the EditView so far down the screen, that the keyboard will hide it, and you won't be able to see what you are writing? Are you sure you want to hide the EditText field from the user?
Are you using a scrollview?

Related

how to keep center relativelayout inside DragLayer in android

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_weight=".1"
android:background="#color/colorPaleGrey2"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20dp">
<TextView
android:id="#+id/meeting_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:gravity="center_horizontal"
android:text="Entrepreneur Meet Up"
android:textColor="#color/blackDark"
android:textSize="20.1sp"
android:textStyle="normal" />
<TextView
android:id="#+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/meeting_text"
android:layout_centerInParent="true"
android:layout_marginTop="10dip"
android:fontFamily="sans-serif-medium"
android:gravity="center_horizontal"
android:lineSpacingExtra="6sp"
android:text="(11:30AM - 4:00PM)"
android:textColor="#color/bluey_grey_three"
android:textSize="14sp"
android:textStyle="normal" />
</RelativeLayout>
<com.kdcos.contsync.utilities.dragview.DragLayer
android:id="#+id/framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/rl_dropView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="40dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/ic_drop_cards" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal|center"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:lineSpacingExtra="10sp"
android:text="Drop Cards Here"
android:textColor="#color/blackDark"
android:textSize="10sp"
android:textStyle="normal" />
</RelativeLayout>
</com.kdcos.contsync.utilities.dragview.DragLayer>
</LinearLayout>
this is my xml i want keep rl_dropView center inside com.kdcos.contsync.utilities.dragview.DragLayer i wrote xml like this i am unable to set it please look my screen please look i want to set dropView center but from my code its coming top left please suggest how to set it in center.
below is my current Screen:
if DragLayer is SubClass of RelativeLayout then it should work otherwise try below solution
Solution 1
<com.kdcos.contsync.utilities.dragview.DragLayer
android:id="#+id/framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/rl_dropView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="40dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/ic_drop_cards" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal|center"
android:fontFamily="sans-serif"
android:gravity="center_horizontal"
android:lineSpacingExtra="10sp"
android:text="Drop Cards Here"
android:textColor="#color/blackDark"
android:textSize="10sp"
android:textStyle="normal" />
</RelativeLayout>
</RelativeLayout>
</com.kdcos.contsync.utilities.dragview.DragLayer>
UPDATE
Solution 2
as I can see android:orientation="vertical" in your code under DragLayer.its mean DragLayer is SubClass of LinearLayout, so in your RelativeLayout just change
android:layout_centerInParent="true"
to:
android:layout_gravity="center_vertical"

RecyclerView is taking full screen to show one message

i am working on a layout for chat screen in which i am using RecyclerView to show messages sent and receive by user but the problem which i am facing is RecyclerView is showing only one message in whole screen and to see other message i have to scroll down or scroll up. i want to show messages next to eachother vertically.
Here is my xml code:-
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/chatparent"
android:background="#color/background">
<include layout="#layout/chattoolbar"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_messages"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:scrollbars="vertical"
android:scrollbarStyle="outsideOverlay"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="0.80"
android:background="#color/colorPrimary" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="0.20"
android:background="#color/black"/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rl_typing"
android:background="#drawable/chatbox"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="10dp"
android:layout_marginStart="15dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="2dp"
>
<Button
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/ic_emoticons"
android:layout_marginTop="8dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="bottom"
android:id="#+id/btn_emoji"
/>
<EditText
android:layout_width="190dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:minLines="1"
android:maxLines="20"
android:lines="8"
android:imeActionId="#+id/send"
android:imeActionLabel="actionSend"
android:imeOptions="actionSend"
android:scrollbars="vertical"
android:textColor="#color/monsoon"
android:textColorHint="#color/dark_gray"
android:id="#+id/et_message"
android:textSize="13sp"
android:hint=" Type Your Message Here..."
android:layout_toEndOf="#id/btn_emoji"
tools:ignore="HardcodedText" />
<Button
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/ic_attachment"
android:layout_marginTop="8dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="bottom"
android:id="#+id/btn_attach"
android:layout_toEndOf="#id/et_message"/>
<Button
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/ic_camera"
android:layout_marginTop="8dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:id="#+id/btn_camera"
android:layout_toEndOf="#id/btn_attach"/>
</RelativeLayout>
<Button
android:layout_width="30dp"
android:layout_height="35dp"
android:id="#+id/btn_send"
android:layout_alignParentTop="true"
android:layout_marginTop="7.5dp"
android:layout_centerHorizontal="true"
android:layout_marginStart="3dp"
android:layout_toEndOf="#id/rl_typing"
android:background="#drawable/ic_send" />
</RelativeLayout>
</LinearLayout>
Here is the recyclerView_item.xml :-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:paddingLeft="10dp">
<TextView
android:id="#+id/username"
style="?android:textAppearanceMedium"
android:textColor="?android:textColorPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textStyle="bold"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/txtOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="#color/black"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#drawable/chat_in"/>
<TextView
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/chat_out"
android:paddingBottom="5dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="5dp"
android:textColor="#color/white"
android:textSize="16dp" />
<TextView
android:id="#+id/lblDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12dp"
android:textColor="#color/colorprimarylight"
android:textStyle="italic"
android:padding="5dp"
/>
</LinearLayout>
</LinearLayout>
Here is the screenshot in which you can see how much space it is producing in between two messages.
set recyclerview item's main layout height "wrap_content"
In child view of recyclerView set xml root to "wrap_content". If you set a flag match_parent it will take all space and you need to scroll your parent view.
In recyclerView_item.xml, you must set your 'main' LinearLayout's height and width match_parent to wrap_content

ListView CHOICE_MODE_SINGLE change color of the radio button

i create costume alert with listView type CHOICE_MODE_SINGLE ,my issue its how to change the color of the radio button,i read some question and understood that i need to change the style but still it dose not working.
photo of my pop alert:
http://imgur.com/a/uBMxt
here is my xml code:
<RelativeLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#color/white"
tools:context="com.example.hercules.animal_app.Activity.ResultFragment">
<RelativeLayout
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginTop="5dp"
android:visibility="visible"
android:layout_centerHorizontal="true"
android:id="#+id/realtiveLaoutListView"
android:layout_width="250dp"
android:layout_height="360dp">
<TextView
android:paddingLeft="15dp"
android:id="#+id/titeleListView"
android:textSize="18dp"
android:layout_centerHorizontal="true"
android:text="Choose animal"
android:textColor="#ff7042"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView
style="#style/myStyle"
android:backgroundTint="#color/colorAppBackGroundButton"
android:layout_below="#id/titeleListView"
android:id="#+id/typeListView"
android:layout_centerHorizontal="true"
android:layout_width="250dp"
android:layout_height="270dp">
</ListView>
<TextView
android:id="#+id/seperator"
android:layout_centerHorizontal="true"
android:layout_width="250dp"
android:layout_below="#id/typeListView"
android:layout_height="1dp"
android:background="#color/gray"/>
<TableRow
android:layout_marginLeft="130dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/seperator"
android:layout_marginTop="5dp">
<TextView
android:id="#+id/cancelButtonChooseArray"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff7042"
android:textSize="15dp"
android:text="Cancel"
/>
<TextView
android:layout_width="30dp"/>
<TextView
android:id="#+id/okButtonChooseArray"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff7042"
android:textSize="15dp"
android:text="OK"
android:layout_below="#id/seperator"/>
</TableRow>
</RelativeLayout>

moving button bar

I have an activity that allows me to enter content. It consists of edit text and button bar. Whenever I what to input something to the edit text, a keyboard pops up and the button bar is on top if it so I can't see what I'm typing if the content is long(it goes behind the button bar). How can i fix it ?
my code is:
<RelativeLayout
android:id="#+id/toplayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/notetop"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="5dp" >
<TextView
android:id="#+id/title_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp" />
<EditText
android:id="#+id/etTitleJoke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/title_text1"
android:background="#android:color/transparent"
android:hint="#string/no_title"
android:imeOptions="actionNext"
android:singleLine="true"
android:textColor="#000000"
android:textSize="18sp" >
</EditText>
</RelativeLayout>
<view
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/etContentJoke"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toplayout"
class="ie.myjokes.LineEditText"
android:background="#android:color/transparent"
android:capitalize="sentences"
android:scrollHorizontally="true"
android:fadingEdge="vertical"
android:gravity="top"
android:padding="5dp"
android:scrollbars="vertical"
android:textColor="#000000"
android:textSize="22sp" >
<requestFocus />
</view>
<LinearLayout
android:id="#+id/footer"
style="#android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="#+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickSave"
android:text="#string/btn_save"
android:textColor="#000000" />
<Button
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickCancel"
android:text="#string/btn_cancel"
android:textColor="#000000" />
</LinearLayout>
nevermind, I added this line into my activity and its gone now. Thank you
android:windowSoftInputMode="adjustPan"

Scroll View is not working properly Android

I Want to create a design like this image .
I want independent scroll on both left and right side
What i have done that i have created a main layout .In that i am inflating the inner design at run time .So the deign is proper now.But i have done some silly mistake .Because of that the the scroll is coming inside the layout .So please see the code and help me i am new in android
Class
void setData(){
flightResult=(LinearLayout)findViewById(R.id.flightResultData);
LinearLayout.LayoutParams flightDetailsLayout = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout.LayoutParams forUnderLine = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
forUnderLine.setMargins(0,0, 0, 0);
flightDetailsLayout.setMargins(0, 40, 0, 0);
for(int i=0;i < 13;i++){
TextView line=new TextView(this);
line.setBackgroundResource(R.layout.shape_line);
line.setLayoutParams(forUnderLine);
if(i!=0){
flightResult.addView(line);
}
LinearLayout flightInformations=(LinearLayout)inflater.inflate(R.layout.flight_details_layout, null);
flightLogo=(ImageView)flightInformations.findViewById(R.id.onewayflightLogo);
flightCompany = (TextView)flightInformations.findViewById(R.id.onewayflightName);
flightLogo.setImageResource(R.drawable.airindia);
flightCompany.setText("AirIndia");
flightResult.addView(flightInformations);
}
TextView dummy=new TextView(this);
dummy.setLayoutParams(flightDetailsLayout);
flightResult.addView(dummy);
}
Main Layout (where i am infalting to flightResultData)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/mainLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/top_bg"
android:orientation="horizontal" >
<ImageView
android:id="#+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_btn"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="75dp"
android:text="#string/flightHeader"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/flightDetailsLayout"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_below="#+id/mainLinearLayout"
android:layout_centerHorizontal="true"
android:background="#drawable/gray_bg123"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/innerflightDetailsLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingLeft="12dp"
android:textSize="12sp"
android:text="Boston to San Fransisco, "
android:textStyle="bold" />
<TextView
android:id="#+id/tripType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="RoundTrip"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/innerTripLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tripDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:textSize="10sp"
android:text="19 Jan 2013 "
android:textStyle="bold"/>
<TextView
android:id="#+id/paxText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="for 1 Adults,0 Childs,O Infants"
android:textSize="12dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/Book"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/tripDate"
android:layout_width="84dp"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:text="Rs 10,2345 "
android:textSize="10sp"
android:layout_weight="1"
android:textStyle="bold" />
<ImageView
android:id="#+id/bookBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:src="#drawable/book" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/sortFlightLayouts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/flightDetailsLayout"
android:background="#drawable/gray_bg123"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DEL-BLR"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:src="#drawable/flight_icon_result" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="25dp"
android:src="#drawable/time" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:src="#drawable/rupee" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/gray_bg123"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BLR-DEL"
android:layout_marginLeft="6dp"
android:layout_marginTop="5dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:src="#drawable/flight_icon_result" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="25dp"
android:src="#drawable/time" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:src="#drawable/rupee" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/flightResultData"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/sortFlightLayouts"
android:layout_marginLeft="8dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/footerLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:background="#drawable/top_bg" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
android:src="#drawable/filter" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_marginTop="5dp"
android:src="#drawable/sort" />
</LinearLayout>
</RelativeLayout>
details_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainResultLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ScrollView
android:id="#+id/returnScrollView"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/oneWayResultData"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/onewayflightLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:src="#drawable/spicejet" />
<TextView
android:id="#+id/onewayflightName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SpiceJet" />
<TextView
android:id="#+id/onewayflightNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9W - 496" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/onewayflightTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="6dp"
android:minLines="1"
android:text="06:00 - 7:05"
android:textSize="12dp" />
<TextView
android:id="#+id/onewayflightDuration"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minLines="1"
android:text="1h 35m | Non Stop"
android:textSize="10dp" />
<TextView
android:id="#+id/onewayflightAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minLines="1"
android:text="Rs 20,0000"
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width="1dp"
android:layout_height="60dp"
android:background="#android:color/darker_gray" />
<ScrollView
android:id="#+id/returnScrollView"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/returnResultData"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/returnflightLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:src="#drawable/spicejet" />
<TextView
android:id="#+id/returnflightName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="Spice jet" />
<TextView
android:id="#+id/returnflightNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="8W - 356" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/returnflightTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="6dp"
android:minLines="1"
android:text="06:00 - 7:05"
android:textSize="12sp" />
<TextView
android:id="#+id/returnflightDuration"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minLines="1"
android:text="1h 35m | Non Stop"
android:textSize="10sp" />
<TextView
android:id="#+id/returnflightAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minLines="1"
android:text="Rs 20,0000"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
I've had a look at the layout XML and have found your problem. In one layout you are trying to define both scrollviews and their contents. You don't want to be doing this. I would also suggest you don't want a scrollview, but a listview.
Take a look at This tutorial on how to create listviews with custom contents and create an arrayadapter to populate it with data.
This is an example of how your main layout could look:
<?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:id="#+id/llHeader"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="4"
android:orientation="horizontal">
<ListView
android:id="#+id/lvDepartures"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<ListView
android:id="#+id/lvArrivals"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="#+id/llFooter"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
This gives you three vertical sections weighted DYNAMICALLY so it looks the same on any device screen in proportions 1:4:1. Then the middle section is split down the middle with two listviews which are independently scrollable which you can populate using an adapter.
Then you want to create a SINGLE layout for "a flight"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="75sp"
android:layout_height="75sp"
android:layout_marginRight="10sp"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:id="#+id/ivDemoIcon"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Demo Name"
android:layout_marginTop="20sp"
android:id="#+id/tvDemoName"
android:layout_toRightOf="#+id/ivDemoIcon"
android:layout_toLeftOf="#+id/ivChevron"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/ivDemoIcon"
android:layout_toLeftOf="#+id/ivChevron"
android:text="Date Version"
android:id="#+id/tvDateVersion"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_below="#+id/tvDemoName"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ivChevron"
android:layout_alignTop="#+id/ivDemoIcon"
android:layout_alignParentRight="true"
android:layout_alignBottom="#+id/ivDemoIcon"/>
</RelativeLayout>
This layout has space for two icons as well as three sections of text nicely layed out. You can move these about and create the layout as you want with the information you want. Always try and make layouts as generic as possible so you can use it over and over.
You can then use your adapter to populate each element of each listview for each flight with an instance of this "flight" layout (I've been too lazy to tweak it to be a flight layout like yours but you should get the gist).
You can then create a header and footer layout which the textviews and imageviews etc can be set at runtime accoring to what flight information you have. For the flight information, I would strongly suggest using a singleton data class accessible from anywhere and store the information in ArrayLists (Listview adapters etc play VERY nicely with arraylists and you can do all sorts of cool things like sorting and filtering)
The beauty of clever coding is making everything as dynamic and reusable as you can. Don't go hardcoding things or creating lots of layouts for the same thing, Reuse and recycle! Will make your job much easier. Hope this has helped

Categories

Resources