2013-11-22 87 views
1

我有一個基本的背景和一個textview我希望放置在背景的底部,但是當textview達到一定的水平時,它開始消失在背景中進一步向下我將textview放在XML中。爲什麼當我將我的textview放在背景的文本底部消失到背景背景中?

<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:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".MainActivity" 
android:background="@drawable/main_background" > 
<TextView 
    android:id="@+id/start_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="537dp" 
    android:text="@string/start" 
    android:textColor="#000000" 
    android:textSize="20sp" /> 
</RelativeLayout> 

與我已粘貼以上僅示出了文本觸摸屏的上半部分以啓動代碼TextView的。文字的下半部分已經消失在我的背景中。只是爲了清楚我沒有將textview移出我的背景,對於那些認爲我已將textview放置在我的背景區域之外的人,它仍然處於我的背景區域。那麼爲什麼我的textviews文本消失了,我放了textview呢?

+0

你可以發佈您的代碼 – Caner

回答

0
保證金頂

使用marginBottom就地然後它會正常工作......

android:layout_marginBottom="20dp" 
0

試試這個..

刪除android:layout_marginTop="537dp"添加android:layout_alignParentBottom="true"

保證金是原因是如果你在250 * 250的屏幕上看到這個佈局,它將不會顯示它從537dp到頁。

<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:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".MainActivity" 
android:background="@drawable/main_background" > 

<TextView 
    android:id="@+id/start_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:text="@string/start" 
    android:layout_alignParentBottom="true" 
    android:textColor="#000000" 
    android:textSize="20sp" /> 
</RelativeLayout> 
0

使用這個,如果你想放置文本視圖在bottom.It然後將這個樣子

Text view at the bottom