1

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>
jedgard
  • 868
  • 3
  • 23
  • 41
  • Possible duplicate of [How do you make a LinearLayout scrollable?](http://stackoverflow.com/questions/4055537/how-do-you-make-a-linearlayout-scrollable) – Flow Aug 27 '16 at 10:02

5 Answers5

3

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

Prakhar
  • 2,270
  • 19
  • 26
2
<?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 
A.R.
  • 2,631
  • 1
  • 19
  • 22
1

Make the child of the ScrollView have android:layout_height="wrap_content" (currently yours has match_parent)

Karakuri
  • 38,365
  • 12
  • 84
  • 104
0

add

android:layout_width="match_parent"
android:layout_height="match_parent"

to your root ScrollView

arianoo
  • 657
  • 14
  • 22
0

I hope this code may be help you.

    android:layout_width="match_parent"
    android:layout_height="match_parent">