2015-04-12 132 views
-2

我有一個包含EditText的ScrollView,但問題是它不能在模擬器和物理設備上正確顯示。任何人都可以看到我的代碼的任何問題?android佈局 - 滾動視圖不顯示

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> 
+0

什麼不顯示,edittext?你能分享這個XML嗎?希望它不是你試圖看到的滾動視圖.. – Kay

回答

0

你嘗試添加下列屬性的滾動型?

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

嘗試使用:

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

您可能需要使用條件:wrap_contentfill_parentmatch_parent因爲使用這些可以讓你的視圖元素相應地調整到設備屏幕,該屏幕可以改變。

另外,您也可以將android:id="@id/myIdentifier"添加到EditText中,以便將其鏈接到您在應用中進行的任何過程。