Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
182 views
in Technique[技术] by (71.8m points)

android - Set a LinearLayout to scroll

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...