-1

我想让屏幕可滚动这是我的全屏

图片

我想在下面筛选:

图片

可以滚动我将如何做到这一点?在我的代码中只有 listview 可滚动并非所有 ui 可滚动我想在三个选项卡“午餐”早餐下方进行滚动,请帮助我

          <?xml version="1.0" encoding="UTF-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#ffffff"
  android:orientation="vertical" >

   <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/editbackground" >

    <ImageButton
        android:id="@+id/btnback"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:background="@android:color/transparent"
        android:paddingBottom="8dp"
        android:paddingTop="8dp"
        android:src="@drawable/myback" />

    <TextView
        android:id="@+id/txtCaption2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/btnback"
        android:paddingBottom="10dp"
        android:paddingLeft="5dp"
        android:paddingTop="10dp"
        android:text="Menues"
        android:textSize="17dp" >
    </TextView>
   </RelativeLayout>

   <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:orientation="vertical" >

       <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="100" >

        <ImageView
            android:id="@+id/imgfourth1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:paddingTop="2dp"
            android:src="@drawable/amlet1" />

        <ImageView
            android:id="@+id/imgfourth2"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:paddingTop="2dp"
            android:src="@drawable/lnch1" />

        <ImageView
            android:id="@+id/imgfourth3"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:paddingTop="2dp"
            android:src="@drawable/supper" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@drawable/border4"
        android:orientation="horizontal"
        android:weightSum="100" >

        <TextView
            android:id="@+id/txtfth1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:gravity="center_horizontal"
            android:text="Breakfast" />

        <TextView
            android:id="@+id/txtfth2"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:gravity="center_horizontal"
            android:text="Lunch" />

        <TextView
            android:id="@+id/txtfth3"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:gravity="center_horizontal"
            android:text="Supper" />
    </LinearLayout>
    </LinearLayout>

    <!-- i want screen below this line scrollable -->

   <LinearLayout
    android:id="@+id/buttonlayout"
    android:layout_width="fill_parent"
    android:layout_height="60sp"
    android:background="#ffffff"
    android:gravity="left|top"
    android:height="60sp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/last_month"
        android:layout_width="20sp"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_marginLeft="10sp"
        android:src="@drawable/calendar_left_arrow_selector" >
    </ImageView>

    <TextView
        android:id="@+id/date_today"
        android:layout_width="fill_parent"
        android:layout_height="60sp"
        android:layout_weight="0.6"
        android:gravity="center"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#000000" >
    </TextView>

    <ImageView
        android:id="@+id/next_month"
        android:layout_width="20sp"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_marginRight="10sp"
        android:src="@drawable/calendar_right_arrow_selector" >
    </ImageView>
      </LinearLayout>

     <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/last_week"
        android:layout_width="50sp"
        android:layout_height="fill_parent"
        android:background="#F2F2F2"
        android:src="@drawable/barrowleft2" >
    </ImageView>

    <TableLayout
        android:id="@+id/table_layout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal"
        android:stretchColumns="0,1,2,3,4,5,6" >

        <TableRow
            android:background="#F2F2F2"
            android:paddingBottom="12dp" >

            <!--
        <TextView
            android:id="@+id/sun"
            android:gravity="center"
            android:text="@string/sunday"
            android:textColor="#000000"/>

            -->

            <TextView
                android:id="@+id/mon"
                android:gravity="center"
                android:text="@string/monday"
                android:textColor="#000000" />

            <TextView
                android:id="@+id/tue"
                android:gravity="center"
                android:text="@string/tuesday"
                android:textColor="#000000" />

            <TextView
                android:id="@+id/wed"
                android:gravity="center"
                android:text="@string/wednesday"
                android:textColor="#000000" />

            <TextView
                android:id="@+id/thur"
                android:gravity="center"
                android:text="@string/thursday"
                android:textColor="#000000" />

            <TextView
                android:id="@+id/fri"
                android:gravity="center"
                android:text="@string/friday"
                android:textColor="#000000" />
            <!--
        <TextView
            android:id="@+id/sat"
            android:gravity="center"
            android:text="@string/saturday"
            android:textColor="#000000"/>

            -->
        </TableRow>

        <TableRow>

            <!--
      <Button
    android:id="@+id/e00"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:background="@drawable/calendar_button_selector"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#D9DBD7" >
       </Button>

            -->

            <Button
                android:id="@+id/e01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/calendar_button_selector"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#D9DBD7" >
            </Button>

            <Button
                android:id="@+id/e02"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/calendar_button_selector"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#D9DBD7" >
      >

            </Button>

            <Button
                android:id="@+id/e03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/calendar_button_selector"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#D9DBD7" >
    >

            </Button>

            <Button
                android:id="@+id/e04"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/calendar_button_selector"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#D9DBD7" >
 >

            </Button>

            <Button
                android:id="@+id/e05"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/calendar_button_selector"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#D9DBD7" >
       >

            </Button>
            <!--
  <Button
    android:id="@+id/e06"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:background="@drawable/calendar_button_selector"
    android:textAppearance="?android:attr/textAppearanceMedium"
      android:textColor="#D9DBD7" > >
  </Button>

            -->
        </TableRow>
    </TableLayout>

    <ImageView
        android:id="@+id/next_week"
        android:layout_width="50sp"
        android:layout_height="fill_parent"
        android:background="#F2F2F2"
        android:src="@drawable/barrrow113" >
    </ImageView>
  </LinearLayout>

  <LinearLayout
    android:id="@+id/lytContent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/txtCopyright"
    android:layout_below="@+id/lytTitlebar"
    android:background="@drawable/border2"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listfourthscrMenu"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:dividerHeight="1dip"
        android:fadeScrollbars="true"
        android:listSelector="@drawable/listview_selector" />
      </LinearLayout>

      </LinearLayout>
4

1 回答 1

1

第一:您只能像这样更改布局:(将您的布局分开到另一个文件 xml)

<?xml version="1.0" encoding="UTF-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#ffffff"
  android:orientation="vertical" >

   <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/editbackground" >

    <ImageButton
        android:id="@+id/btnback"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:background="@android:color/transparent"
        android:paddingBottom="8dp"
        android:paddingTop="8dp"
        android:src="@drawable/myback" />

    <TextView
        android:id="@+id/txtCaption2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/btnback"
        android:paddingBottom="10dp"
        android:paddingLeft="5dp"
        android:paddingTop="10dp"
        android:text="Menues"
        android:textSize="17dp" >
    </TextView>
   </RelativeLayout>

   <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:orientation="vertical" >

       <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="100" >

        <ImageView
            android:id="@+id/imgfourth1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:paddingTop="2dp"
            android:src="@drawable/amlet1" />

        <ImageView
            android:id="@+id/imgfourth2"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:paddingTop="2dp"
            android:src="@drawable/lnch1" />

        <ImageView
            android:id="@+id/imgfourth3"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:paddingTop="2dp"
            android:src="@drawable/supper" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@drawable/border4"
        android:orientation="horizontal"
        android:weightSum="100" >

        <TextView
            android:id="@+id/txtfth1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:gravity="center_horizontal"
            android:text="Breakfast" />

        <TextView
            android:id="@+id/txtfth2"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:gravity="center_horizontal"
            android:text="Lunch" />

        <TextView
            android:id="@+id/txtfth3"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="33"
            android:gravity="center_horizontal"
            android:text="Supper" />
    </LinearLayout>
    </LinearLayout>

  <LinearLayout
    android:id="@+id/lytContent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/txtCopyright"
    android:layout_below="@+id/lytTitlebar"
    android:background="@drawable/border2"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listfourthscrMenu"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:dividerHeight="1dip"
        android:fadeScrollbars="true"
        android:listSelector="@drawable/listview_selector" />
  </LinearLayout>

</LinearLayout>

创建一个新文件 header.xml 并粘贴您在上面剪切的所有内容。

在您膨胀布局时的代码中: ListView listView = findViewById(....); 您创建一个 headerView: View headerView = LayoutInflater.from(context).inflate(R.layout.header, null); 然后 listView.addHeaderView(headerView);

当然,像 ImageView last_month 这样的标题视图中的每个视图都可以通过 lastMonthView = headerView.findViewById(....) 进行搜索;

清楚吗?

于 2013-08-17T07:55:33.533 回答