android - 顶部的Android视图ScrollView LinearLayout
问题描述
我想获得巨大的视野,我必须滚动。我想在我的代码中始终在电话屏幕上获得一部分视图是 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>
如果您想保持视图静态和其他可滚动并将该视图保持在滚动视图之外......
推荐阅读
- mysql - 如何在具有相同日期的交易的会计表中按交易日期排序
- python - 如何从带有连接的数据库查询中生成嵌套 JSON?使用 Python / SQLAlchemy
- php - 在子文件夹中安装 laravel,而不是子域
- scala - 如何使用 akka-http 创建自定义解组器来处理参数列表?
- hibernate - 如何与休眠中的特定列关联?
- android - onchange方法:在flutter中下拉列表里面
- c - 如何使函数返回动态分配的二维数组?
- python - 如何确定我的 python 使用 OS 或 Sys 安装在哪里
- javascript - Lodash getOr for null
- javascript - ng-if & ng-show 无法切换表格的可见性