0

在下面的代碼:的LinearLayout滾動型中不顯示按鈕

<ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     xmlns:android="http://schemas.android.com/apk/res/android"> 

    <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingLeft="16dp" 
      android:paddingRight="16dp" 
      android:orientation="vertical"> 

     <TextView 
       android:layout_marginTop="20dp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="27sp" 
       android:text="@string/create_card_text"/> 

     <TextView 
       android:layout_marginTop="20dp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="24sp" 
       android:textColor="#ff949494" 
       android:text="@string/create_card_info_text_one"/> 

     <EditText 
       android:id="@+id/name" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="40dp" 
       android:hint="Name"/> 

     <EditText 
       android:id="@+id/email" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="20dp" 
       android:inputType="textEmailAddress" 
       android:hint="Email"/> 

     <TextView 
       android:id="@+id/phone_number" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textSize="20sp" 
       android:layout_marginLeft="10dp" 
       android:layout_marginTop="20dp" 
       android:hint="Phone Number"/> 

     <Button 
       android:id="@+id/next_button" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="20dp" 
       android:layout_marginLeft="280dp" 
       android:text="@string/create_card_next_button" 
       android:onClick="next"/> 

    </LinearLayout> 

</ScrollView> 

按鈕只是沒有顯示出來。什麼可能是錯的?

+2

您的邊距是huuuuge! – Merlevede

+0

@K_K嘗試下面的代碼,讓我知道它是否在工作。 – InnocentKiller

回答

1

試試這個。

您已設置android:layout_marginLeft="280dp"所以用

android:layout_marginLeft="20dp"或別的東西代替這

所以基本上你的按鈕的代碼會是這個樣子

<Button 
    android:id="@+id/next_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="20dp" 
    android:layout_marginLeft="20dp" 
    android:text="@string/create_card_next_button" 
    android:onClick="next"/> 

我想你已經設置的容左280dp這是造成問題,並使其出於你的屏幕將其設置爲20dp或根據您的屏幕要求,因爲你已經設置其他,它應該工作。

相關問題