0

我在这个问题上花了几个小时,我希望有人能帮助我。如果问题很愚蠢,请提前抱歉,我对 android 开发还很陌生,而且,我正在使用一个已经生成大量代码的应用程序构建器。我基本上是在尝试用我想要的来调整这段代码......

问题只是关于 xml 布局,我认为它不涉及代码。我想在这个屏幕的底部显示一个简单的按钮。

所以我有这个屏幕,它在网格中构建了一组按钮。我还在顶部显示了一个广告横幅。这些按钮的参数是通过 Web 界面上的 Web 应用程序构建器指定的。这些按钮没有问题。它们在下面的屏幕布局中正确显示:

    <?xml version="1.0" encoding="UTF-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/containerView"
android:background="@android:color/transparent"    
android:padding="0dip"
android:layout_margin="0dip"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     ads:adUnitId="123"
                     ads:adSize="SMART_BANNER"
                     ads:testDevices="123"
                     ads:loadAdOnCreate="true">
</com.google.ads.AdView>



    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/verticalScrollView" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">

        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/tableLayout" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent">
        </TableLayout>

    </ScrollView>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/containerViewHorizontal"
            android:background="@android:color/transparent"    
            android:padding="0dip"
            android:layout_margin="0dip"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/containerViewHorizontalBottom"
                    android:background="@android:color/transparent"    
                    android:padding="0dip"
                    android:layout_margin="0dip"
                    android:orientation="vertical"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/horizontalScrollView" 
                    android:layout_width="fill_parent" 
                    android:layout_height="wrap_content">

                    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                        android:id="@+id/containerHorizontalButtons"
                        android:background="@android:color/transparent"    
                        android:padding="0dip"
                        android:layout_margin="0dip"
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">

                    </LinearLayout>

                </HorizontalScrollView> 

            </LinearLayout>

    </RelativeLayout>

现在我要做的是在这组按钮的底部添加一个不属于通过网络应用程序生成器生成的列表,而是手动创建的按钮:

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

我已经处理了此按钮的代码,它运行良好,但我无法在屏幕底部显示它。

我想这与屏幕的总体布局有关。我不得不承认我完全迷失在一系列相互嵌套的布局中,我不明白到底在做什么。

如果这有帮助,我已经设法在屏幕顶部显示我的按钮,甚至在我的广告横幅下方。但不是在底部。

另外,如果这有帮助,我猜其中一个布局占用了整个高度空间(滚动视图?),我要添加的按钮的高度为 0...

非常感谢您的宝贵时间,如果您能帮助我!

4

1 回答 1

1

Juyt 实现了一个线性布局,而不是列表和按钮的相对布局。然后给列表一个 0dp 的高度和一个 1 的权重按钮将具有任何属性:

<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:orientation="vertical" >

<ListView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" >
</ListView>

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Button" />

</LinearLayout>
于 2012-09-19T14:11:20.273 回答