Android - Android界面隐藏的按钮

时间:2017-04-21 11:28:12

标签: android

它在预览中显示良好,但是当我运行时,界面隐藏了最后一个按钮。我该如何解决这个问题?

编辑:现在我想起来,我认为这是TitleBar的大小。我该如何解决这个问题?

enter image description here

XML CODE:

<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: comercial@amob.pt"
        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>

4 个答案:

答案 0 :(得分:0)

预览中没有操作栏,但在模拟器中你获得了操作栏,这就是为什么隐藏最后一个按钮的原因,我想在清单文件中检查该特定布局的主题。如果你想要动作栏,你需要添加scrollview

答案 1 :(得分: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: comercial@amob.pt"
            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>

答案 2 :(得分: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>

答案 3 :(得分:0)

ScrollView 放入 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: comercial@amob.pt"
            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>