【问题标题】:How to implement ScrollView for my layout containing both text, image and ListView如何为包含文本、图像和 ListView 的布局实现 ScrollView
【发布时间】:2013-05-06 10:12:53
【问题描述】:

我正在尝试将 ScrollView 添加到包含各种 TextView、ImageView 和 ListView 的布局中。我希望能够滚动的原因是因为所有的文本和图像几乎占据了所有的空间并且留给 ListView 的空间很少。

我不知道如何实施这个艰难的。 这是我用于布局的 XML 代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/pubInfoImg"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/pubInfoWelcome"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingLeft="10dp" />

        <TextView
            android:id="@+id/pubInfoTapsNo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="5"
            android:padding="10dp" />
    </LinearLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="0.7dip"
        android:layout_centerVertical="true"
        android:background="@android:color/holo_blue_dark" />

    <TextView
        android:id="@+id/pubInfoAddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp" />

    <TextView
        android:id="@+id/pubInfoUrl"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp" />

    <TextView
        android:id="@+id/pubInfoOpenhours"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp" />

    <ListView
        android:id="@+id/tapsListview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#BABABA"
        android:divider="@android:color/transparent"
        android:dividerHeight="0.0sp"
        android:footerDividersEnabled="true"
        android:headerDividersEnabled="true" />

    </LinearLayout>

【问题讨论】:

    标签: android-layout android-listview android-linearlayout android-xml android-scrollview


    【解决方案1】:

    如果您想在列表末尾设置 imageview 或 textview,那么您可以使用 ListView.addFooterView(footerView);它将在android中listview的页脚添加视图

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-19
      • 1970-01-01
      • 2020-12-19
      相关资源
      最近更新 更多