java - Android-如何让 ScrollView 占据屏幕的整个宽度?

标签 java android width scrollview

我试图让我的 ScrollView 占据屏幕的整个宽度。我在其所在行和 ScrollView 上使用了匹配父级。但是它仍然不会扩展到屏幕的整个宽度。我尝试过其他东西,例如 fill:viewport 但效果不佳。 链接到当前输出的屏幕截图/image/2EUlE.jpg 我在 ScrollView 上设置了粉红色的背景色

ScrollView 及其所在行的 XML 代码

 <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
         >

        <ScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_span="3"
            android:background="@color/corn"
            android:fillViewport="true" >

            <TableLayout
                android:id="@+id/completeTable"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

            </TableLayout>
        </ScrollView>

    </TableRow>

插入 ScrollView 的表行代码(不认为这是问题

    <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
  >

        <TextView
            android:id="@+id/task"
            android:layout_height="wrap_content"
            android:layout_weight="1"
             />

        <Button
            android:id="@+id/delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:text="@string/deleteItem" />

</TableRow>

最佳答案

您应该考虑为您的应用程序屏幕使用LinearLayout/RelativeLayout/FrameLayout!

我认为你的问题是因为你的主TableLayout中有很多tablerows占据了你的ScrollView。您在 wrap_content 上设置了 TableRow,这可能会压扁您的 ScrollView!

关于java - Android-如何让 ScrollView 占据屏幕的整个宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24335682/

相关文章:

jquery - 选择的harvethq动态调整宽度

width - 如何在 Blueprintjs 中进行选择使用(或模拟)填充?或者甚至是固定宽度?

java - 使用 DigestInputStream 从同一个 InputStream 计算多个校验和

java - 如何配置gradle嵌套jar文件必须在不压缩的情况下存储?

java - GridLayout 抛出非法组件位置

android - 5.1 like elevation Shadow under a View using onDraw 方法

java - 我们如何在 TreeMap 中使用异构键

java - 有没有一种方法可以根据单选按钮单击通过代码传递文本值?

android - URLConnection - 读取响应后无法写入请求正文

css - Div 未扩展到 100%(默认行为)