android - 线性布局或水平 ScrollView 正在切断内容

标签 android xml android-layout horizontalscrollview

我正在尝试实现一个简单的屏幕,其中有一个带有书籍条目的水平 ScrollView 。我遇到的问题是它似乎过早地切断,切断了条目。我看过与此类似的其他问题,他们的修复似乎并没有解决我的问题,所以我不确定如何处理这个问题。

这是切断的样子:

enter image description here

这是我的代码:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#D3D3D3" >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="fill"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/textView11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="2dp"
            android:text="@string/af"
            android:textAppearance="?android:attr/textAppearanceLarge" />
        <HorizontalScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#A1A1A1" >
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="fill_horizontal|end"
                android:orientation="horizontal" >
                <RelativeLayout
                    android:id="@+id/relative1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
                    <ImageView
                        android:id="@+id/imageView1"
                        android:layout_width="168dp"
                        android:layout_height="258dp"
                        android:layout_marginLeft="5dp"
                        android:layout_marginRight="5dp"
                        android:layout_marginTop="5dp"
                        android:contentDescription="@string/cd"
                        android:src="@drawable/af1" />
                    <TextView
                        android:id="@+id/textLabel1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/imageView1"
                        android:layout_centerInParent="true"
                        android:singleLine="true"
                        android:text="Guilty Wives" />
                </RelativeLayout>
                /*RelativeLayout repeats with different data, cut for brevity*/
            </LinearLayout>
        </HorizontalScrollView>
    </LinearLayout>
</ScrollView>

最佳答案

这是一个从 Unresolved 已知错误:( https://code.google.com/p/android/issues/detail?id=20088 ), 但这是对我有用的代码。 技巧是设置水平 ScrollView 的宽度以包裹内容,并设置其下方的线性(或相对)布局的宽度以匹配父级。

<HorizontalScrollView
    android:id="@+id/group_scroller"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal" >

    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
    <RadioGroup
        android:id="@+id/choices_group"
        android:layout_width="wrap_content"
        android:orientation="horizontal"

        android:paddingTop="4dp"
        android:paddingBottom="4dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:gravity="center_horizontal" />
    </LinearLayout>
</HorizontalScrollView>

关于android - 线性布局或水平 ScrollView 正在切断内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22120867/

相关文章:

android - 为什么我在创建/更新通知时会收到 RemoteServiceException?

java - 将 java 中的文件从本地 xml 文件解析为新文本文件时出现 ArrayOutOfBoundException

xml - 检查 xml 节点是否不存在并做一些事情而不是失败

java - 我没有收到自定义选项卡的图标

java - View 设置为 GONE 时不调用 Android onScrolled

java - 安卓Java : Show the value only of `id` when a listrow is selected

android - 如何获取 View 的监听器

java - 处理 jackson 的不良 Json 属性值

java - 即使列表不为空,emptyView 也始终显示

android - 当我从列表中选择一个项目时回来