开发者

Is it possible to add different views inside a scrollview in android?

开发者 https://www.devze.com 2023-04-09 14:49 出处:网络
I am not able add different views inside a scrollview. How can I add a textView and a editText inside a scrol开发者_运维百科lViewYes you can add. But use a Layout and put your components there.

I am not able add different views inside a scrollview. How can I add a textView and a editText inside a scrol开发者_运维百科lView


Yes you can add. But use a Layout and put your components there.

Example <ScrollView><LinearLayout> *Views* </LinearLayout></ScrollView>


Sample Code

<ScrollView
            android:id="@+id/scroll"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <LinearLayout
                android:id="@+id/innerly1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:gravity="center"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/heading1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/background_light"
                    android:gravity="center"
                    android:scrollbars="vertical"
                    android:textColor="#FF0000" />

                <ImageView
                    android:id="@+id/image1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_launcher" />

                <TextView
                    android:id="@+id/desc1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/background_light"
                    android:gravity="center"
                    android:scrollbars="vertical"
                    android:textColor="#FF0000" />
            </LinearLayout>
        </ScrollView>
0

精彩评论

暂无评论...
验证码 换一张
取 消