簡體   English   中英

頂部的 Android 視圖 ScrollView LinearLayout

[英]Android view ScrollView LinearLayout on top

我想獲得巨大的視野,我必須滾動。 我想在我的代碼中始終在電話屏幕上獲得一部分視圖是我想始終在屏幕上顯示的LinearLayout 在我的LinearLayout我將layout_alignParentTop但當我滾動時它消失了。

我的代碼:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/cor"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true">

                    <ImageView
                        android:id="@+id/iv_photo"
                        android:layout_width="0sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />

                    <RelativeLayout
                        android:layout_width="0sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="3.5">

                        <TextView
                            android:id="@+id/tv_user_name"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="Jan Nowak"
                            android:textColor="@color/background_tutorial"
                            android:textSize="@dimen/text_normal_size"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/tv_user_mail"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/tv_user_name"
                            android:text="jan.nowak@gmail.com"
                            android:textColor="@color/background_tutorial"
                            android:textSize="@dimen/text_normal_size" />

                    </RelativeLayout>

                    <ImageView
                        android:id="@+id/iv_settings"
                        android:layout_width="0sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1" />
                </LinearLayout>

            </RelativeLayout>

        </RelativeLayout>

    </ScrollView>

</RelativeLayout>

做了一些改動:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/cor"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        >

        <ImageView
            android:id="@+id/iv_photo"
            android:layout_width="0sp"
            android:layout_height="match_parent"
            android:layout_weight="1" />

        <RelativeLayout
            android:layout_width="0sp"
            android:layout_height="wrap_content"
            android:layout_weight="3.5">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tv_user_name"
                android:textColor="#000000"
                android:textSize="17sp"
                android:text="Jan Nowak"
                android:textStyle="bold"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/tv_user_name"
                android:id="@+id/tv_user_mail"
                android:textColor="#000000"
                android:textSize="17sp"
                android:text="jan.nowak@gmail.com"
                />

        </RelativeLayout>

        <ImageView
            android:id="@+id/iv_settings"
            android:layout_width="0sp"
            android:layout_height="match_parent"
            android:layout_weight="1" />
    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </RelativeLayout>
    </ScrollView>



</RelativeLayout>

如果您想保持視圖靜態和其他可滾動,並將該視圖保持在滾動視圖之外....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM