【问题标题】:ImageView to Bottom Right of Screen with Large ScrollView above itImageView 到屏幕右下角,上方有大 ScrollView
【发布时间】:2015-12-09 11:49:38
【问题描述】:

我总是尝试将 ImageView 放置在屏幕的右下角。它的后面是一个垂直滚动视图,它占据了整个屏幕,并且总是比用户屏幕高。无论用户在 ScrollVIew 上的哪个位置,我都试图将 ImageView 始终固定在屏幕的右下角。

我下面的布局确实正确定位了图像,但它没有位于它下方的 ScrollView 之上(并且从 ScrollView 的底部裁剪)。无论用户滚动到哪里,如何让滚动视图扩展到屏幕底部并保持 ImageView 准确无误?

关于如何实现这一点的任何建议?

目前看起来是这样的(注意 ScrollView 的黑色底部切掉了):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:scrollbars="none">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            android:orientation="vertical">
            <TextView
                android:id="@+id/groupname"
                android:paddingLeft="50px"
                android:textSize="35px"
                android:background="#FFFFFF"
                android:textColor="#000000"
                android:text="abc"
                android:layout_width="fill_parent"
                android:layout_height="450dp" />
            <TextView
                android:paddingLeft="50px"
                android:textSize="35px"
                android:background="#FFFF00"
                android:textColor="#000000"
                android:text="abc"
                android:layout_width="fill_parent"
                android:layout_height="450dp" />
        </LinearLayout>
    </ScrollView>
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="6dp"
        android:background="@android:color/transparent"
        android:src="@drawable/camera" />
</LinearLayout>

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    试试这个

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:local="http://schemas.android.com/apk/res-auto"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:background="@android:color/transparent">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/ImageView1"
        android:id="@+id/ScrollView1"
        android:scrollbars="none">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:orientation="vertical">
            <TextView
                android:id="@+id/groupname"
                android:paddingLeft="50px"
                android:textSize="35px"
                android:background="#FFFFFF"
                android:textColor="#000000"
                android:text="abc"
                android:layout_width="fill_parent"
                android:layout_height="450dp" />
            <TextView
                android:paddingLeft="50px"
                android:textSize="35px"
                android:background="#FFFF00"
                android:textColor="#000000"
                android:text="abc"
                android:layout_width="fill_parent"
                android:layout_height="450dp" />
        </LinearLayout>
    </ScrollView>
        <ImageView
         android:id="@+id/ImageView1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="true"
         android:layout_alignParentRight="true"
         android:layout_alignParentEnd="true"
         android:background="@android:color/transparent"
         android:layout_marginRight="6dp"
         android:src="@drawable/camera" />
    
    </RelativeLayout>
    

    【讨论】:

    • 感谢您的回答,但它会导致相同的布局。我已经尝试使背景透明,但如果来自主要相对布局,则为黑色。问题是让图像视图位于滚动视图的顶部
    • 如果我没记错的话,你的相机图标周围有黑色区域吗?
    • 是的,它在相机图标后面仍然是黑色的(相同的黑色矩形)。黑色是RelativeLayout背景
    • 检查您的应用主题是暗色还是什么,然后将white 之类的颜色赋予相对布局而不是transparent
    猜你喜欢
    • 2013-05-20
    • 2012-04-02
    • 1970-01-01
    • 2019-01-05
    • 2020-06-02
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多