安卓 : Set scroll view position to start at 80% from top of screen

标签 android android-layout

我正在努力实现这样的目标:

 -  |-------------------|<-------Phone screen
 |  ||-----------------||
 |  ||                 ||
80% ||                 ||
 |  ||                 ||
 |  ||                 |<--------Image View  (fills screen, background)
 -  |||---------------|||
 |  |||               |||
20% |||               |<---------Scroll View (starts after 80% of parent view)
 |  ||-----------------||
 -  |-------------------|  

ImageView 有一个图像填充背景,scrollView 在高度的 80% 之后开始。有人可以帮助我了解如何在所有设备尺寸上实现这一目标吗?

最佳答案

使用layout_weight

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

        <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

<LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <View
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="8" />

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="2">

        </ScrollView>

</LinearLayout>

</RelativeLayout>

关于安卓 : Set scroll view position to start at 80% from top of screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18942964/

相关文章:

android layout-land 和 onConfigurationChanged

android - 如何修复在 Nexus 设备中出现移动的导航栏?

Android如何将google帐户传递给webview

android - 动态单选按钮

android - 在 FragmentStatePagerAdapter NPE 中运行数据库查询

android - 自定义 Alertdialog 宽度大于布局 xml 中显示的宽度

android - 布局预览不显示 ActionBar 溢出选项

java - 更改导航栏颜色,Android

java - 如何将一些函数从 Activity 转换为 Fragment?

android - 在更改 GridView 以链接 xml 布局时显示 log cat 错误