Hey guys, im pretty new to android platform and have a really simple question. Im putting buttons as layouts with text boxes, but im running out of room. How would i make it possible for the user to scroll down to view more buttons and stuff. For example, if i have 6 buttons, and 3 are in the field of view, i wanna be able to scroll with my finger and be able to see those buttons as I scroll.
Thanks for the help guys
-Localgamer
You can put your controls(widgets: buttons, labels etc) inside a ScrollView. Check the documentation of the class for details : http://developer.android.com/reference/android/widget/ScrollView.html
Something like:
<ScrollView ..>
<TextView .../>
<Button .../>
</ScrollView>
Try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/proffrag"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#ffffff"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="30dip"
android:paddingRight="30dip"
android:paddingTop="10dip" >
<EditText
android:id="#+id/firstname"
style="#style/custom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rounded_edittext"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
android:drawableLeft="#drawable/usernamem"
android:drawablePadding="10dp"
android:ems="10"
android:hint="#string/firstname"
android:inputType="textCapWords"
android:singleLine="true" >
<requestFocus />
</EditText>
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<EditText
android:id="#+id/lastname"
style="#style/custom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rounded_edittext"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
android:drawableLeft="#drawable/usernamem"
android:drawablePadding="10dp"
android:ems="10"
android:hint="#string/lastname"
android:inputType="textCapWords"
android:singleLine="true" />
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<EditText
android:id="#+id/username"
style="#style/custom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rounded_edittext"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_#-."
android:drawableLeft="#drawable/usernamem"
android:drawablePadding="10dp"
android:ems="10"
android:hint="#string/username"
android:singleLine="true" />
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<EditText
android:id="#+id/email"
style="#style/custom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rounded_edittext"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_#-.,"
android:drawableLeft="#drawable/emailm"
android:drawablePadding="10dp"
android:ems="10"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:singleLine="true" />
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<TextView
android:id="#+id/selecttopic"
style="#style/custom"
android:layout_width="match_parent"
android:layout_height="20dp"
android:ems="10"
android:singleLine="true"
android:text="#string/selecttopic" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radiosubject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/rbtn_selector"
android:button="#null"
android:gravity="center"
android:padding="5dp"
android:text="Subject"
android:textColor="#drawable/rbtn_textcolor_selector" />
<RadioButton
android:id="#+id/radiocourse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/rbtn_selector"
android:button="#null"
android:gravity="center"
android:padding="5dp"
android:text="Courses"
android:textColor="#drawable/rbtn_textcolor_selector" />
</RadioGroup>
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<TextView
android:id="#+id/selectgen"
style="#style/custom"
android:layout_width="match_parent"
android:layout_height="20dp"
android:ems="10"
android:singleLine="true"
android:text="#string/selectgen" />
<RadioGroup
android:id="#+id/radioGroup2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radiomale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/rbtn_selector"
android:button="#null"
android:gravity="center"
android:padding="5dp"
android:text="#string/selectmale"
android:textColor="#drawable/rbtn_textcolor_selector" />
<RadioButton
android:id="#+id/radiofemale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/rbtn_selector"
android:button="#null"
android:gravity="center"
android:padding="5dp"
android:text="#string/selectfemale"
android:textColor="#drawable/rbtn_textcolor_selector" />
</RadioGroup>
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/proftextgender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
<Button
android:id="#+id/browse"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/mycustom_button"
android:minHeight="40dp"
android:text="#string/browse"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="10dp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<LinearLayout
android:id="#+id/firs"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:orientation="horizontal"
android:paddingLeft="20dp" >
<TextView
android:id="#+id/browseimage"
android:layout_width="109dp"
android:layout_height="wrap_content"
android:layout_weight="1.17"
android:maxLines="2" />
</LinearLayout>
<View
android:id="#+id/vi"
android:layout_width="20dp"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/firs" >
</View>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="#id/vi"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:id="#+id/upload"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/mycustom_button"
android:minHeight="30dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="#string/upload"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="5dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingLeft="30dp"
android:paddingRight="30dp" >
<Button
android:id="#+id/savechagnes"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/mycustom_button"
android:minHeight="40dp"
android:text="#string/savechanges"
android:textColor="#ffffff" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="5dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Related
First of all sorry for my english, This is my first question on StackOverflow, but I've learned a lot here .
Now I have a problem, which I couldn't solve. I have a framelayout with some elements. In android 4.x, Menu Panel's buttons onClick method doesn't fire. menupanel work to be in scroolview but in android 2.x buttons and layout work without problem as i want. I didn't find a problem.
Thanks for the help!
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<!-- Menu Panel starts here -->
<RelativeLayout
android:scrollbars="none"
android:id="#+id/menuPanel"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/gray_bg"
android:gravity="right"
android:orientation="vertical">
<TextView
android:id="#+id/menu_title_1"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:background="#353535"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:text="#string/menu_title"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold" >
</TextView>
<View
android:id="#+id/menu_item_divider_5"
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/menu_title_1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#b5b5b5" />
<Button
android:id="#+id/aktifgorevlerim"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="#+id/menu_item_divider_5"
android:background="#drawable/buton"
android:gravity="center_vertical"
android:onClick="AYARLAR_Click"
android:paddingLeft="15dp"
android:text="#string/item_1"
android:textColor="#android:color/white" >
</Button>
<View
android:id="#+id/menu_item_divider_2"
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/aktifgorevlerim"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#b5b5b5" />
<Button
android:id="#+id/tamamlanmisgorevlerim"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="#+id/menu_item_divider_2"
android:background="#drawable/buton"
android:gravity="center_vertical"
android:onClick="GOREVLERIM_Click"
android:paddingLeft="15dp"
android:text="#string/item_2"
android:textColor="#android:color/white" />
<View
android:id="#+id/menu_item_divider_1"
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/tamamlanmisgorevlerim"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:background="#b5b5b5" />
<Button
android:id="#+id/hakkinda"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_below="#+id/menu_item_divider_1"
android:background="#drawable/buton"
android:gravity="center_vertical"
android:onClick="HAKKINDA_Click"
android:paddingLeft="15dp"
android:text="HAKKINDA"
android:textColor="#android:color/white" >
</Button>
<Button
android:id="#+id/cikisyap"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="0dp"
android:background="#drawable/buton2"
android:gravity="center_vertical"
android:onClick="CIKISYAP_Click"
android:paddingLeft="15dp"
android:text="#string/item_4"
android:textColor="#android:color/white" >
</Button>
</RelativeLayout>
<!-- menuPanel ends here -->
<ScrollView
android:id="#+id/scrolpanel"
android:layout_width="wrap_content"
android:fillViewport="false"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="#+id/slidingPanel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:gravity="left"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:background="#drawable/blue_bg" >
<View
android:id="#+id/header_vertical_divider_1"
android:layout_width="2dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/menuViewButton"
android:background="#drawable/engraved_bg" />
<ImageView
android:id="#+id/menuViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:clickable="true"
android:contentDescription="#string/description"
android:src="#drawable/icon_menu"
android:visibility="visible" />
<TextView
android:id="#+id/titlebar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Talep Detay Formu"
android:textColor="#color/White"
android:textSize="20sp" />
</RelativeLayout>
<EditText
android:id="#+id/Textgorevbaslik"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:ems="10"
android:gravity="top"
android:hint="Görev Başlığı"
android:textSize="10pt" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/Textgorevaciklama"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="top"
android:hint="Açıklama"
android:lines="6"
android:singleLine="false"
android:textSize="10pt" >
</EditText>
<CheckBox
android:id="#+id/Checkgrupgorevi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center"
android:onClick="CHECKBOX_click"
android:text="Grup Görevi mi ?" >
</CheckBox>
<Spinner
android:id="#+id/spinnergorevkisilistesi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center" />
<Spinner
android:id="#+id/spinnergorevprojelistesi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center" />
<Spinner
android:id="#+id/spinnergorevdurumlistesi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center" />
<CheckBox
android:id="#+id/Checkgorulmegorevi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center"
android:text="Sadece Yönetici ve Uzman Görebilsin ?" >
</CheckBox>
<Spinner
android:id="#+id/spinnergorevonceliksirasi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center" />
<Button
android:id="#+id/btngorevekle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:background="#drawable/roundedbutton"
android:height="35dp"
android:onClick="GOREVEKLE"
android:text="EKLE"
android:textColor="#color/White"
android:textStyle="bold"
android:width="100dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:height="100dp"/>
</LinearLayout>
</ScrollView>
</FrameLayout>
onClick method
public void GOREVLERIM_Click(View view){
Intent intent = new Intent(GorevEkleActivity.this, GorevActivity.class);
startActivity(intent);
}
Thanks for answers. I found the solution. I put scrollview in a linearlayout. Problem was solved.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ScrollView
android:id="#+id/scrolpanel"
android:layout_width="match_parent"
android:fillViewport="false"
android:layout_height="match_parent"
android:orientation="vertical"
>
.
.
.
</ScrollView>
</LinearLayout>
I have been reading many posts here in stackoverflow about making a linear layout scroll and have applied all the specific advices to make it work but it still does not show on the left hand side. I am new to android and not sure what i am doing wrong.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView1">
<LinearLayout
android:id="#+id/expense"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="start"
android:orientation="vertical"
tools:context=".Expense" >
<LinearLayout
android:id="#+id/tedsts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/testffg"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".30"
android:text="Matter"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/tedssss"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".65"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<TextView
android:id="#+id/tetxttx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/gray_dark"
android:visibility="invisible" />
<EditText
android:id="#+id/teetttsss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all"
android:ems="10"
android:gravity="top"
android:hint="dgdfgfgf"
android:inputType="textMultiLine" />
<LinearLayout
android:id="#+id/tesssstt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all_clickable_selector"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/yttrree"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".20"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/rrrefffe"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".75"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<RadioButton
android:id="#+id/dfgrrrrr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Cost"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gergrerrr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded_all_clickable"
android:ems="10"
android:hint=""
android:inputType="numberDecimal"
android:singleLine="true" >
</EditText>
<RadioButton
android:id="#+id/rerreee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gggrrrrre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/roundede"
android:ems="10"
android:hint="grrrergg."
android:inputType="numberDecimal"
android:singleLine="true"
android:visibility="gone" >
</EditText>
<EditText
android:id="#+id/65gfhhggf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded"
android:ems="10"
android:hint=""
android:inputType="numberDecimal" >
</EditText>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/gfhgfhtrhrth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="15dp"
android:visibility="gone" />
<TextView
android:id="#+id/ghjjhhhgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/expense_TV_total"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="#+id/hgjhhghjhg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/save_selector" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
use this :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView ...>
<LinearLayout ...>
...
...
</LinearLayout>
</ScrollView>
and set hieght to
android:layout_height="wrap_content"
as Karakuri said
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
//Your Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100">
// First Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing First Sub layout
// Second Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing Second Sub layout
similarly for 3rd,4rth,5th sub layouts and so on........
</LinearLayout> // Finishing Main Layout
</ScrollView> // Finishing ScrollView
Make the child of the ScrollView have android:layout_height="wrap_content" (currently yours has match_parent)
add
android:layout_width="match_parent"
android:layout_height="match_parent"
to your root ScrollView
I hope this code may be help you.
android:layout_width="match_parent"
android:layout_height="match_parent">
I want to use auto look up for searching .
I have partially created this layout . This is my XML code.
Now how can i use autol lookup in this?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="#drawable/logo_demo" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_marginTop="10dp"
android:background="#drawable/flight_bar"
android:orientation="horizontal" >
<TextView
android:id="#+id/roundtripTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginTop="5dp"
android:layout_weight="0.01"
android:text="Round trip"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/OneWayTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginTop="5dp"
android:layout_weight="0.01"
android:text="OneWay"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/multicityTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginTop="5dp"
android:layout_weight="0.03"
android:text="MultiCity"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:id="#+id/linearLayout4"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:background="#drawable/from2"
android:orientation="horizontal" >
<TextView
android:id="#+id/fromTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="7dp"
android:layout_weight=".05"
android:text="From" />
<TextView
android:id="#+id/toTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="7dp"
android:layout_weight=".05"
android:text="To" />
</LinearLayout>
</RelativeLayout>
i have to use a auto look up box same below to the to i have to use autolook up and in the middle of both there will be image .So i have done till from and to part now i am not able to create to separate auto look up box below from and to.
Try this layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/imageView1"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/roundtripTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#FF0000FF"
android:gravity="center"
android:text="Round trip"
android:textColor="#android:color/white"
android:textSize="20sp" />
<TextView
android:id="#+id/OneWayTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#FF0000FF"
android:gravity="center"
android:text="OneWay"
android:textColor="#android:color/white"
android:textSize="20sp" />
<TextView
android:id="#+id/multicityTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#FF0000FF"
android:gravity="center"
android:text="MultiCity"
android:textColor="#android:color/white"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical" >
<EditText
android:id="#+id/fromTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:gravity="center_horizontal"
android:hint="From" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="LON"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="London Great Britain"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/darker_gray"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical" >
<EditText
android:id="#+id/toTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:gravity="center_horizontal"
android:hint="To" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="DXB"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Dubai United Arab Emirates"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Edit
Put below layout after "from/to" layout.
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/linear3"
android:orientation="horizontal" >
<AutoCompleteTextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="bottom"
android:text="LON" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/darker_gray"
android:src="#drawable/ic_launcher" />
<AutoCompleteTextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="bottom"
android:text="DXB" />
</LinearLayout>
I have this code:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="85dp"
android:ems="10"
android:inputType="textPostalAddress"
android:text="neshto">
<requestFocus />
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" >
<Button
android:id="#+id/buttonOk"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:text="Ok" />
<Button
android:id="#+id/buttonCancel"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:text="Cancel" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</LinearLayout>
<Spinner
android:id="#+id/size"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Spinner
android:id="#+id/color"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
I cant post image with the result I'm looking for, but I want the two buttons Ok and Cancel to be below, the two spinners to stand almost right down to the text field. But I can't handle these layouts. Can somebody give me an idea? I've tried it so many times, but it's still not looking the way I want.
Try this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="85dp"
android:ems="10"
android:inputType="textPostalAddress"
android:text="neshto" >
<requestFocus />
</EditText>
<Spinner
android:id="#+id/size"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Spinner
android:id="#+id/color"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" >
<View
android:id="#+id/strut"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerHorizontal="true" />
<Button
android:id="#+id/buttonOk"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_gravity="center_horizontal"
android:layout_toLeftOf="#id/strut"
android:layout_weight="0.5"
android:text="Ok" />
<Button
android:id="#+id/buttonCancel"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="center_horizontal"
android:layout_toRightOf="#id/strut"
android:layout_weight="0.5"
android:text="Cancel" />
</RelativeLayout>
</LinearLayout>
Use a RelativeLayout instead of LinearLayout as layout container:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="85dp"
android:ems="10"
android:inputType="textPostalAddress"
android:text="neshto" >
<requestFocus />
</EditText>
<Spinner
android:layout_below="#+id/editText"
android:id="#+id/size"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Spinner
android:layout_below="#+id/size"
android:id="#+id/color"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" >
<Button
android:id="#+id/buttonOk"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:text="Ok" />
<Button
android:id="#+id/buttonCancel"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:text="Cancel" />
</LinearLayout>
</RelativeLayout>
I am using a FrameLayout with some EditText controls and a QuickContactBadge. Its fine till here. when I run the app, I am able to see all the controls, but QuickContactBadge not appearing in the layout.
What I need to do to make it visible? Did I miss anything?
This is my layout file,
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="#drawable/pattern1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:orientation="vertical" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<QuickContactBadge
android:id="#+id/quickContactBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:scaleType="centerCrop" />
<EditText
android:id="#+id/txtlastname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/edttxtfirstname"
android:layout_marginTop="50dp"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName"
android:textColor="#000000" />
<EditText
android:id="#+id/edttxtfirstname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName"
android:textColor="#000000" >
<requestFocus />
</EditText>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" >
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtheadingphone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/editText2"
android:layout_gravity="center"
android:layout_marginRight="70dp"
android:layout_weight="0.63"
android:gravity="center_vertical"
android:text="Phone"
android:textColor="#ffffffff" />
<ImageButton
android:id="#+id/imgbtnaddphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_add" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/btnchphone"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone"
android:textColor="#ffffffff" />
<EditText
android:id="#+id/edttxtphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.48"
android:ems="10"
android:gravity="center"
android:hint="Phone Number"
android:inputType="phone"
android:textColor="#000000" />
<ImageButton
android:id="#+id/imgbtndelphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_delete" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" >
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtheadingaddress"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/editText2"
android:layout_gravity="center"
android:layout_marginRight="70dp"
android:layout_weight="0.63"
android:gravity="center_vertical"
android:text="Address"
android:textColor="#ffffffff" />
<ImageButton
android:id="#+id/imgbtnaddAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_add" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/btnAddress"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textColor="#ffffffff" />
<EditText
android:id="#+id/edttxtaddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="Address"
android:inputType="textPostalAddress"
android:textColor="#000000" />
<ImageButton
android:id="#+id/imgbtndeladdress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_delete" />
</LinearLayout>
<EditText
android:id="#+id/edttxtcity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="City"
android:textColor="#000000" />
<EditText
android:id="#+id/edttxtstate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="State"
android:textColor="#000000" />
<EditText
android:id="#+id/edttxzipcode"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="ZipCode"
android:inputType="phone"
android:textColor="#000000" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" >
</View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtemail"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginRight="70dp"
android:layout_weight="0.63"
android:gravity="center_vertical"
android:text="Email"
android:textColor="#ffffffff" />
<ImageButton
android:id="#+id/imgbtnaddemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_add" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="#+id/btnchemail"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textColor="#ffffffff" />
<EditText
android:id="#+id/edttxtemail"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_weight="0.48"
android:ems="10"
android:gravity="center"
android:hint=""
android:inputType="textEmailAddress"
android:textColor="#000000" />
<ImageButton
android:id="#+id/imgbtndelemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_input_delete" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#AA000000" >
<Button
android:id="#+id/btnsave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="addCustomerDetails"
android:text="Save"
android:textColor="#000000"
>
</Button>
<Button
android:id="#+id/btncancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"
android:textColor="#000000"
android:onClick="canceladdcustomer">
</Button>
</LinearLayout>
</FrameLayout>
Please correct me or provide any useful links, so that I will come to know my mistake.
Thanks for your valuable help!!