![](/img/trans.png)
[英]Top view in a LinearLayout embedded in a ScrollView only half visible
[英]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.