android布局 - scrollview不显示

时间:2015-04-12 11:35:45

标签: android scrollview

我有一个包含EditText的ScrollView,但问题是它在模拟器和物理设备上无法正常显示。任何人都可以看到我的代码有任何问题?

XML代码段

<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:background="@drawable/background2"
tools:context="com.jack.cheng.buddhistcopy.Activity1">
<ScrollView
    android:layout_width="300dp"
    android:layout_height="300dp"
    android:id="@+id/scrollView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:fillViewport="true"
    android:isScrollContainer="true"
    android:saveEnabled="true">
    <TableLayout
        android:id="@+id/sutra"
        android:layout_width="295dp"
        android:layout_height="295dp"
        android:orientation="vertical"
        >
        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <EditText
                android:text="Test"
                android:layout_width="10dp"
                android:layout_height="10dp"
                >
            </EditText>
        </TableRow>
    </TableLayout>
    </ScrollView>
</RelativeLayout>

2 个答案:

答案 0 :(得分:0)

您是否尝试将以下属性添加到ScrollView?

xmlns:android="http://schemas.android.com/apk/res/android"

答案 1 :(得分:0)

尝试使用:

 <EditText
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="TestText"
      />

您可能希望使用以下条件:wrap_contentfill_parentmatch_parent,因为这些条件允许您的视图元素根据设备屏幕进行相应调整,这可能会有所不同。

此外,您可能希望向该EditText添加android:id="@id/myIdentifier",以便将其链接到您在应用中进行的任何过程。