代码之家  ›  专栏  ›  技术社区  ›  xxmilcutexx

横向/滚动视图中缺少视图

  •  0
  • xxmilcutexx  · 技术社区  · 8 年前

    我希望标题保持静态,只有正文应该滚动。

    sample image

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/padding_screenEdge"
        xmlns:android="http://schemas.android.com/apk/res/android">
    
        <include layout="@layout/header_inspection"/>
    
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <include layout="@layout/fragment_body"/>
    
        </ScrollView>
    </LinearLayout>
    

    <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="wrap_content"
                  android:orientation="vertical"
                 tools:context="my.mimos.fssm.kpkt.layout.Lain2Generik">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:background="@color/form_background">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:background="@color/form_background">
    
                <LinearLayout...> //header
    
                <LinearLayout...> //column item 1
    
                <LinearLayout...> //column item 2
    
                <LinearLayout...> //column item 3
    
                <LinearLayout...> //column item 4
    
            </Linearlayout>
    </LinearLayout>
    

    收割台检查。xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="5"
        android:orientation="horizontal">
    
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="start"
            android:divider="@drawable/divider_vertical"
            android:orientation="horizontal"
            android:showDividers="middle"
            android:dividerPadding="12dp">
    
            <TextView
                android:id="@+id/btn_prev"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="end"
                android:padding="@dimen/text_padding"
                android:text="@string/btn_sebelumnya"/>
    
            <TextView
                android:id="@+id/btn_nxt"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="end"
                android:padding="@dimen/text_padding"
                android:text="@string/btn_seterusnya"/>
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="end">
    
            <TextView
                style="@style/marks"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="end"
                android:text="Markah : "/>
    
            <TextView
                android:id="@+id/cur_marks"
                style="@style/marks"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="start"
                android:text="0"/>
    
        </LinearLayout>
    </LinearLayout>
    
    2 回复  |  直到 8 年前
        1
  •  0
  •   Sai Jayant    8 年前

    <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="wrap_content"
                  android:orientation="vertical"
                 tools:context="my.mimos.fssm.kpkt.layout.Lain2Generik">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:background="@color/form_background">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:background="@color/form_background">
    
                <LinearLayout...> //header
                <ScrollView                    
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
    
                <LinearLayout...> //column item 1
    
                <LinearLayout...> //column item 2
    
                <LinearLayout...> //column item 3
    
                <LinearLayout...> //column item 4
    </ScrollView>
            </Linearlayout>
    </LinearLayout>

    尝试将列包装在scrollview的侧面,并将标题保持在scrollview之外

        2
  •  0
  •   xxmilcutexx    8 年前

    我发现了它的问题。显然我应该包括 layout_height layout_width 在里面 标签因此,正确的代码 主_活动 应该是:

    <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="wrap_content"
                  android:orientation="vertical"
                  android:padding="@dimen/padding_screenEdge"
                  tools:context="my.mimos.fssm.kpkt.layout.Lain2Generik">
    
        <include layout="@layout/header_inspection"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"/>
    
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <include layout="@layout/fragment_lain2_generik"/>
    
        </ScrollView>
    
    
    </LinearLayout>