2017-04-21 65 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