简体   繁体   English

是否可以在Android中使用静态文本和水平滚动创建Listview?

[英]Is it possible to create a Listview with a Static text and a horizontal scroll in android?

在此处输入图片说明

Here First Text will be stationary. 在这里,第一个文本将保持不变。 For remaining items i need the horizontal scroll and when scrolling entire list rows should be scrolled left or right. 对于其余项目,我需要水平滚动,并且在滚动整个列表时,应向左或向右滚动。 can we do this by simple listviews in android? 我们可以通过android中的简单listviews做到这一点吗?

Replace the LinearLayouts with ListsViews. 用ListsViews替换LinearLayouts。 The idea is to put the second ListView inside HorizontalScrollView. 想法是将第二个ListView放入Horizo​​ntalScrollView内。

<xml version="1.0" encoding="utf-8"?>
    <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"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.idokov.layouttests.MainActivity">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginRight="5dp">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="What is Lorem Ipsum?" />
            </LinearLayout>


            <HorizontalScrollView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:singleLine="true"
                        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." />
                </LinearLayout>

            </HorizontalScrollView>

        </LinearLayout>
    </RelativeLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM