【问题标题】:Make First Button fixed on scroll view使第一个按钮固定在滚动视图上
【发布时间】:2012-05-21 11:18:00
【问题描述】:

我需要将第一个按钮固定在屏幕上,因为它就像应用程序徽标。我更改了 ScrollView,但随后出现“滚动视图只能有一个孩子”之类的错误。

下面是xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res/com.apperspray.scarface"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg1"
android:orientation="vertical" >

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

    <LinearLayout
        android:id="@+id/home_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:orientation="vertical" >

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/masthead"
            android:layout_width="fill_parent"
            android:layout_height="80dp"
            android:background="@drawable/mastbg"
            android:gravity="left|center" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button01"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button02"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button03"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button04"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button05"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button06"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button07"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button08"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button09"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button10"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button11"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button12"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button13"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button14"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button15"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button16"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button17"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button18"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button19"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button20"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button21"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button22"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button23"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button24"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button25"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>

        <WebView
            android:id="@+id/accesskey"
            android:layout_width="fill_parent"
            android:layout_height="100dp" />
    </LinearLayout>
</ScrollView>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res/com.murdersquirrel.newboard"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/home_layout"
    android:layout_alignParentBottom="true"
    android:background="#ffffff"
    android:gravity="bottom"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="a14fb507753fada" />
</LinearLayout>

按钮,

<Button
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/masthead"
        android:layout_width="fill_parent"
        android:layout_height="80dp"
        android:background="@drawable/mastbg"
        android:gravity="left|center" >
    </Button>

作为应用程序的标志,所以我不喜欢它是滚动的。我需要把它固定在上面。

谢谢!

【问题讨论】:

    标签: android xml android-layout android-emulator


    【解决方案1】:

    只需将您的 xml 设计为...

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res/com.apperspray.scarface"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg1"
    android:orientation="vertical" >
    
    <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/masthead"
            android:layout_width="fill_parent"
            android:layout_height="80dp"
            android:background="@drawable/mastbg"
            android:gravity="top"
            android:layout_alignParentTop="true">
        </Button>
    
    <ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollview1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/masthead">
    
    <LinearLayout
        android:id="@+id/home_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:orientation="vertical" >
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button01"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button02"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button03"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button04"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button05"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button06"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button07"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button08"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button09"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button10"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button11"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button12"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button13"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button14"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button15"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button16"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button17"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button18"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button19"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button20"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button21"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button22"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button23"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button24"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <Button
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/button25"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbg"
            android:gravity="left|center"
            android:padding="10dp"
            android:shadowColor="#f5f5f5"
            android:shadowDx="1"
            android:shadowDy="1"
            android:shadowRadius="1"
            android:textColor="#6c6c6c"
            android:textSize="10pt" >
        </Button>
    
        <WebView
            android:id="@+id/accesskey"
            android:layout_width="fill_parent"
            android:layout_height="100dp" />
    </LinearLayout>
    

        <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="a14fb507753fada" />
    

    【讨论】:

    • 好吧,我收到 [2012-05-21 17:42:33 - New Board] XML 文件中的错误:正在中止构建。
    • 错误:在包 'android' 中找不到属性 'layout_parentTop' 的资源标识符
    【解决方案2】:

    像这样设计你的 xml 文件

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg1"
    android:orientation="vertical">
    
    <Your logout Button/>
    
    <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollview1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    
        <LinearLayout
            android:id="@+id/home_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#000000"
            android:orientation="vertical" >
    <Your Button/>
    <Your Button/>
    <Your Button/>
    <Your Button/>
    ...
    ....
    ...
    <Your Button/>
    <Your Button/>
    
    
    </LinearLayout>
    </ScrollView>
    
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:ads="http://schemas.android.com/apk/res/com.murdersquirrel.newboard"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/home_layout"
        android:layout_alignParentBottom="true"
        android:background="#ffffff"
        android:gravity="bottom"
        android:orientation="vertical" >
    
        <com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"
            ads:adUnitId="a14fb507753fada" />
    </LinearLayout>
    
    </LinearLayout>
    

    【讨论】:

    • 嗯,第一个按钮用作徽标,所以我不希望它与其他元素一起滚动,但这样它会滚动,对吗?谢谢!
    • 我更新了我的答案,检查一次。我在滚动视图上方添加了注销按钮。那么它就可以正常工作了。
    【解决方案3】:

    在 FrameLayout 和 SetScrollview 上分别保留按钮到您需要在布局中滚动的元素,希望这会起作用

    【讨论】:

    • 通过java代码将滚动视图添加到线性布局现在你通过xml做了希望这有帮助
    • 我的客户不想更改 java 文件中的任何内容。
    【解决方案4】:

    然后在相对布局或线性布局下添加您的按钮,而不是在滚动视图下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-30
      • 1970-01-01
      • 2019-08-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多