2017-04-21 94 views
-3

它在預覽中很好地顯示,但是當我運行時,最後一個按鈕被界面隱藏。我怎麼解決這個問題?Android - 由Android界面隱藏的按鈕

編輯:現在我想到了它,我認爲這是TitleBar的大小。我該如何解決這個問題?

enter image description here

XML代碼:

<FrameLayout 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" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
tools:context="com.example.tiagosilva.amob_android.ContactUsFragment" 
android:background="@color/AMOB_gray"> 


<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:padding="20dp" 
    android:weightSum="3"> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="AMOB Headquarters" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="Rua Padre Domingos Joaquim Pereira,1249" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" /> 

    <TextView 
     android:id="@+id/textView4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="4760-563 Louro" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" 
     android:background="@color/AMOB_gray"/> 

    <TextView 
     android:id="@+id/textView5" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="Vila Nova de Famalicão, Portugal" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" /> 

    <TextView 
     android:id="@+id/textView7" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="Phone: (+351) 252 330 900" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" /> 

    <TextView 
     android:id="@+id/textView8" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="Fax: (+351) 252 376 887" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" /> 

    <TextView 
     android:id="@+id/textView9" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="E-mail: [email protected]" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" /> 

    <TextView 
     android:id="@+id/textView6" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fontFamily="serif" 
     android:text="GPS: 41º 26'.16''N/8º32'31.89''W" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textColor="@android:color/white" /> 


    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/gps_amob" 
     android:id="@+id/gps_map" 
     android:layout_weight="3" 
     android:layout_marginTop="10dp" 
     android:scaleType="fitXY"/> 

    <Button 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:id="@+id/btn_emailUs" 
     android:background="@drawable/round_buttons" 
     android:layout_marginTop="10dp" 
     android:text="Email us"> 
    </Button> 

    <Button 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:id="@+id/btn_callUs" 
     android:background="@drawable/round_buttons_green" 
     android:layout_marginTop="10dp" 
     android:text="Call Us"> 
    </Button> 

</LinearLayout> 

+1

把你的FrameLayout在滾動型 – Pehlaj

+0

你需要的,如果烏拉圭回合使用的LinearLayout滾動型 – Spartan

+0

不使用的LinearLayout ,使其滾動型 或 使用的RelativeLayout的孩子與重力:底部,把2個按鈕首先,把地圖容器佈局後在這些按鈕上方的XML將解決您的問題。 – shijin

回答

0

存在預覽沒有動作條,但在模擬器你要動作條,這就是爲什麼在得到隱藏的最後一個按鈕,我想檢查清單文件中特定佈局的主題。雅如果u想動作條中,你需要添加滾動型

+0

仍然發生相同的https://i.gyazo.com/0f5ca1bec604b6fdea56a323ef7c3b04.png – adiajdiadj

+0

但現在你必須能夠滾動你的所有按鈕。如果你想讓所有的按鈕在屏幕上可見而不滾動。你將不得不手動調整硬編碼高度的所有小部件是錯誤的過程。 –

+0

我不是。我一直滾動到底部,android界面仍然隱藏按鈕。 – adiajdiadj

0
Action bar is causing problem as in preview there is no Action bar..check this layout. 

<FrameLayout 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" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context="com.example.tiagosilva.amob_android.ContactUsFragment" 
    android:background="@color/AMOB_gray"> 
    <ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillviewport="true" 
    > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:padding="20dp" 
     android:weightSum="3"> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="AMOB Headquarters" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Rua Padre Domingos Joaquim Pereira,1249" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="4760-563 Louro" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" 
      android:background="@color/AMOB_gray"/> 

     <TextView 
      android:id="@+id/textView5" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Vila Nova de Famalicão, Portugal" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView7" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Phone: (+351) 252 330 900" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView8" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Fax: (+351) 252 376 887" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView9" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="E-mail: [email protected]" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView6" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="GPS: 41º 26'.16''N/8º32'31.89''W" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 


     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/gps_amob" 
      android:id="@+id/gps_map" 
      android:layout_weight="3" 
      android:layout_marginTop="10dp" 
      android:scaleType="fitXY"/> 

     <Button 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:id="@+id/btn_emailUs" 
      android:background="@drawable/round_buttons" 
      android:layout_marginTop="10dp" 
      android:text="Email us"> 
     </Button> 

     <Button 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:id="@+id/btn_callUs" 
      android:background="@drawable/round_buttons_green" 
      android:layout_marginTop="10dp" 
      android:text="Call Us"> 
     </Button> 

    </LinearLayout> 
    </ScrollView> 
    </FrameLayout> 
+0

仍然發生一樣https://i.gyazo.com/0f5ca1bec604b6fdea56a323ef7c3b04.png – adiajdiadj

0

你的UI是太大的設備來呈現,包你的佈局在滾動視圖上不能顯示整個設備使得UI的垂直滾動UI一次:

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

//Put your layout here 

</ScrollView> 
+0

仍然發生相同的https://i.gyazo.com/0f5ca1bec604b6fdea56a323ef7c3b04。 png – adiajdiadj

+0

您是否嘗試向下滾動UI? –

0

滾動型XML也可以增加你的按鈕的邊距下

<FrameLayout 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" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context="com.example.tiagosilva.amob_android.ContactUsFragment" 
    android:background="@color/AMOB_gray"> 
    <ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillviewport="true" 
    > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:padding="20dp" 
     android:weightSum="3"> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="AMOB Headquarters" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Rua Padre Domingos Joaquim Pereira,1249" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="4760-563 Louro" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" 
      android:background="@color/AMOB_gray"/> 

     <TextView 
      android:id="@+id/textView5" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Vila Nova de Famalicão, Portugal" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView7" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Phone: (+351) 252 330 900" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView8" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="Fax: (+351) 252 376 887" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView9" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="E-mail: [email protected]" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 

     <TextView 
      android:id="@+id/textView6" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fontFamily="serif" 
      android:text="GPS: 41º 26'.16''N/8º32'31.89''W" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textColor="@android:color/white" /> 


     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/gps_amob" 
      android:id="@+id/gps_map" 
      android:layout_weight="3" 
      android:layout_marginTop="10dp" 
      android:scaleType="fitXY"/> 

     <Button 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:id="@+id/btn_emailUs" 
      android:background="@drawable/round_buttons" 
      android:layout_marginTop="10dp" 
      android:layout_marginBottom="10dp" 
      android:text="Email us"> 
     </Button> 

     <Button 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:id="@+id/btn_callUs" 
      android:background="@drawable/round_buttons_green" 
      android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp" 
      android:text="Call Us"> 
     </Button> 

    </LinearLayout> 
    </ScrollView> 
    </FrameLayout> 
+0

仍然發生https://i.gyazo.com/0f5ca1bec604b6fdea56a323ef7c3b04.png – adiajdiadj