2012-05-29 98 views
1

我在RelativeLayout中有一個EditText,其中EditText中文本的頂部被截斷。我曾嘗試增加EditText的填充,但即使在20dp時,文本仍然會被裁剪。在EditText中截斷文本的頂部

我試圖在這裏發佈圖片,但顯然我沒有足夠的名譽爲stackoverflow允許我發佈一個。想象一下像你在小學時那樣在中間水平放置一條帶紋線的紙。虛線以上的文字會被裁剪掉。

這裏是我的layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 
<RelativeLayout android:layout_width="fill_parent" 
       android:layout_height="wrap_content"> 
    <TextView android:id="@+id/questionTextView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="0dp" 
       android:layout_marginLeft="10dp" 
       android:textSize="16dp" 
       android:text="Audit Question"/> 
    <RadioButton android:id="@+id/answerRadioButton" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/questionTextView" 
       android:layout_alignLeft="@id/questionTextView" 
       android:layout_marginTop="5dp" 
       android:checked="true" 
       android:textSize="16dp" 
       android:text="audit answer"/> 
    <EditText android:id="@+id/commentEditText" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/answerRadioButton" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="20dp" 
       android:layout_marginBottom="10dp" 
       android:padding="20dp" /> 
</RelativeLayout> 

任何幫助將不勝感激。

回答

0

我不清楚爲什麼這個工作,但是當我在EditText小部件的底部添加一個TextView緩衝區時,文本不再被截斷。

我加了這一點:

<TextView android:layout_width="fill_parent" 
      android:layout_height="5dp" /> 

而且的EditText內的文本現在看起來,因爲它應該。

1

Difference between a View's Padding and Margin

Padding將增加的空間是你EditText視圖的內容和自身的邊界constaints,這意味着它可能是問題,爲什麼你的EditText正在clipped--它contraining本身。嘗試將android:layout_marginTop添加到您的EditText,而不是在它與RadioButton之間創建空間。

+0

我曾嘗試過,但也沒有奏效。 – NLam