Android 按钮不显示

Android 按钮不显示,android,android-layout,Android,Android Layout,这是我的xml代码(我遵循了这一点,但它不起作用): 这是一个图形: 当我的webview变得太高时,我的按钮不会显示。我该怎么办?谢谢:D试试下面的布局,希望对你有用 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pa

这是我的xml代码(我遵循了这一点,但它不起作用):


这是一个图形:


当我的webview变得太高时,我的按钮不会显示。我该怎么办?谢谢:D

试试下面的布局,希望对你有用

<LinearLayout 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:weightSum="10" >

    <WebView
        android:id="@+id/webChapter"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center_horizontal" >

        <Button
            android:id="@+id/btnMenu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Back To Menu" />

        <Button
            android:id="@+id/btnNavi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Example" />

        <Button
            android:id="@+id/btnQuestion"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Quiz" />
    </LinearLayout>
</LinearLayout>


上面的代码将在webview中显示按钮。如果您可以使用webview上方的按钮,那么也不需要使用权重。您可以将webview放在按钮布局下方。

试试下面的布局,希望对您有用

<LinearLayout 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:weightSum="10" >

    <WebView
        android:id="@+id/webChapter"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="center_horizontal" >

        <Button
            android:id="@+id/btnMenu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Back To Menu" />

        <Button
            android:id="@+id/btnNavi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Example" />

        <Button
            android:id="@+id/btnQuestion"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Quiz" />
    </LinearLayout>
</LinearLayout>

上面的代码将在webview中显示按钮。如果您可以使用webview上方的按钮,那么也不需要使用权重。您可以将webview置于按钮布局下方。

尝试以下操作:

<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" >

<WebView
    android:id="@+id/webChapter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true"
    android:layout_above="@+id/linearlayout"/>

<LinearLayout
    android:id="@+id/linearlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" 
    android:layout_alignParentBottom="true">

    <Button
        android:id="@+id/btnMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back To Menu" />

    <Button
        android:id="@+id/btnNavi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Example" />

    <Button
        android:id="@+id/btnQuestion"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Quiz" />
</LinearLayout>

希望这将对您有所帮助

尝试以下方法:

<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" >

<WebView
    android:id="@+id/webChapter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true"
    android:layout_above="@+id/linearlayout"/>

<LinearLayout
    android:id="@+id/linearlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" 
    android:layout_alignParentBottom="true">

    <Button
        android:id="@+id/btnMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back To Menu" />

    <Button
        android:id="@+id/btnNavi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Example" />

    <Button
        android:id="@+id/btnQuestion"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Quiz" />
</LinearLayout>


希望这将帮助您

嗨,请尝试下面的一个

<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" >

<WebView
    android:id="@+id/webChapter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true"
    android:layout_alignBottom="@+id/btnLayout"/>

<LinearLayout
    android:id="@+id/btnLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" 
    android:layout_below="@+id/webChapter">

    <Button
        android:id="@+id/btnMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back To Menu" />

    <Button
        android:id="@+id/btnNavi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Example" />

    <Button
        android:id="@+id/btnQuestion"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Quiz" />
</LinearLayout>

您好,请尝试以下方法

<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" >

<WebView
    android:id="@+id/webChapter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true"
    android:layout_alignBottom="@+id/btnLayout"/>

<LinearLayout
    android:id="@+id/btnLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" 
    android:layout_below="@+id/webChapter">

    <Button
        android:id="@+id/btnMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back To Menu" />

    <Button
        android:id="@+id/btnNavi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Example" />

    <Button
        android:id="@+id/btnQuestion"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Quiz" />
</LinearLayout>

您可以为webview设置一个高度,或者为LinearLayout定义一个id,并在webview上设置属性
android:layout\u,以确保webview位于按钮上方,而不是浮动在按钮上方

试着这样做:

<WebView
    android:id="@+id/webChapter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/lowerBar"
    android:layout_alignParentTop="true"/>

<LinearLayout
    android:id="@+id/lowerBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" 
    android:layout_alignParentBottom="true">

您可以为webview设置一个高度,或者为LinearLayout定义一个id,并在webview上设置属性
android:layout\u,以确保webview位于按钮上方,而不是浮动在按钮上方

试着这样做:

<WebView
    android:id="@+id/webChapter"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/lowerBar"
    android:layout_alignParentTop="true"/>

<LinearLayout
    android:id="@+id/lowerBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal" 
    android:layout_alignParentBottom="true">


谢谢:D但是使用下面的android:layout\u=“webviewid”和上面的android:layout\u=“linearid”有什么不同?为什么第一个不起作用,而第二个起作用?@BlazeTama通过设置android:layout_below=“webviewid”,您可以指示您的布局在您的webview下方,但如果您的webview太大,您的布局将不在屏幕上。通过设置android:layout_over=“linearid”,您可以指示您的webview位于布局之上。我知道一开始很难理解(我记得:p),但我唯一能做的建议就是继续练习,这样会让你更清楚。另一种方法是将你的relativelayout替换为垂直线性,使你的webview 0dp高度和1weight,并与wrap_内容成线性。感谢你的解释,是的,这有点难,但你的解释让我更好地理解:DThanks:D但是使用android:layout_下文=“webviewid”有什么不同android:layout_over=“linearid”?为什么第一个不起作用,而第二个起作用?@BlazeTama通过设置android:layout_below=“webviewid”,您可以指示您的布局在您的webview下方,但如果您的webview太大,您的布局将不在屏幕上。通过设置android:layout_over=“linearid”,您可以指示您的webview位于布局之上。我知道一开始很难理解(我记得:p),但我唯一能做的建议就是继续练习,这样会让你更清楚。另一种方法是将你的relativelayout替换为垂直线性,使你的webview 0dp高度和1weight,并与wrap_内容线性。感谢你的解释,是的,这有点难,但你的解释让我更好地理解:D谢谢你的回答让我的应用程序强制关闭。这是因为android:layout_低于=“@+id/webChapter”。这是一个循环依赖项:DOops,只需删除下面的部分谢谢:D但你的回答使我的应用程序强制关闭。这是因为android:layout_低于=“@+id/webChapter”。它是一个循环依赖项:DOops,只需删除下面的部分