【问题标题】:Listview at the bottom that i have designed for android doesnt show up entirely我为android设计的底部列表视图没有完全显示
【发布时间】:2017-06-14 22:54:12
【问题描述】:

你可以看到下面属于布局设计的代码。

<LinearLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="5dp">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

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

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

                <ImageView
                        android:id="@+id/profilePic2"
                        android:layout_width="@dimen/feed_item_profile_pic"
                        android:layout_height="@dimen/feed_item_profile_pic"
                        android:scaleType="fitCenter" >
                    </ImageView>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:paddingLeft="@dimen/feed_item_profile_info_padd" >

                    <TextView
                        android:id="@+id/name2"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:textSize="@dimen/feed_item_profile_name"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/timestamp2"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:textColor="@color/timestamp"
                        android:textSize="@dimen/feed_item_timestamp" />

                    <TextView
                        android:text="TextView"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:id="@+id/textCategory2"
                        android:layout_weight="1"
                        android:textStyle="normal|bold"/>

                </LinearLayout>

            </LinearLayout>

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


                <TextView
                    android:id="@+id/content2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="5dp"
                    android:paddingLeft="@dimen/feed_item_status_pad_left_right"
                    android:paddingRight="@dimen/feed_item_status_pad_left_right"
                    android:paddingTop="@dimen/feed_item_status_pad_top"
                    android:layout_weight="1"/>

                <ImageView
                    android:id="@+id/contentImage2"
                    android:layout_width="match_parent"
                    android:background="@color/white"
                    android:scaleType="fitCenter"
                    android:visibility="visible"
                    android:cropToPadding="false"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    app:srcCompat="@drawable/bg_parent_rounded_corner"
                    android:layout_weight="1"/>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:isScrollContainer="false"
                    android:keepScreenOn="false"
                    android:measureWithLargestChild="false"
                    android:verticalScrollbarPosition="defaultPosition"
                    android:paddingBottom="10dp">

                    <TextView
                        android:text="@string/yorumlar"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:id="@+id/textView"
                        android:layout_weight="1"/>

                    <ListView
                        android:layout_width="match_parent"
                        android:id="@+id/comList"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="false"
                        android:clipChildren="false"
                        android:headerDividersEnabled="false"
                        />
                </LinearLayout>

            </LinearLayout>

        </LinearLayout>
    </ScrollView>

</LinearLayout>

我们可以在屏幕顶部看到帖子的详细信息,cmets 在屏幕底部。尽管滚动视图包含列表视图并且我有“layout_height:wrap_content”,但评论并没有完全显示。出现第一条评论,但其他评论不显示滚动。

感谢您的回答

Screenshot

【问题讨论】:

    标签: android android-layout listview android-studio scrollview


    【解决方案1】:

    您必须更改以下内容才能显示列表:

    1. 将根线性布局的高度从包装内容更改为匹配父级。

       android:layout_height="match_parent"
      
    2. 做同样的事情来滚动视图

      android:layout_height="match_parent"
      

    3 现在改变 listview 的高度,我给了 android:layout_height="500dp" 这个。您可以根据自己的要求进行调整。

    注意:如果不提供静态高度,列表视图将无法在滚动视图中工作。所以你必须给高度为 400..500dp 或者你可以删除滚动视图。

    【讨论】:

    • 谢谢,我会试试这个解决方案
    • 欢迎 İbrahim Ürüker :)
    猜你喜欢
    • 1970-01-01
    • 2015-04-17
    • 2021-04-29
    • 2014-05-05
    • 1970-01-01
    • 2013-10-24
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    相关资源
    最近更新 更多