草庐IT

android - ScrollView 内的 fragment 使黑色背景闪烁

coder 2023-12-03 原文

我在其中一个 Activity 中有一个 LinearLayout 作为主要布局。我用Scrollview封装了LinearLayout。布局包含一个显示谷歌地图的 fragment ,但在滚动时它给出了黑色背景。我通过在 FrameLayout 中使用透明背景解决了这个问题。黑色背景消失了,但在滚动过程中,我在 map 周围看到闪烁的黑色边缘。如何删除这个?我尝试将 Scrollview 的背景设置为白色,但没有任何变化可见。

Activity 的 XML 是 --

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:baselineAligned="false"
android:orientation="vertical"
android:overScrollMode="ifContentScrolls"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:showDividers="none" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="45dp"
    android:background="#ec4d1d" >

    <TextView
        android:id="@+id/friend_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="7dp"
        android:background="@drawable/near_you_bg"
        android:gravity="center_horizontal|center_vertical"
        android:padding="6dp"

        android:textColor="#FFFFFF"
        android:textSize="15sp"
        android:textStyle="bold"
        android:typeface="sans" />

    <Button
        android:id="@+id/btnInviteFriends"
        android:layout_width="30dp"
        android:layout_height="25dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="7dp"
        android:background="@drawable/menu_bg"
        android:onClick="inviteFriends" />

</RelativeLayout>

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="81dp"
    android:background="@drawable/list_bg"
    android:orientation="vertical" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:shrinkColumns="*"
        android:stretchColumns="*" >

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_marginTop="4dp"
            android:gravity="center_vertical|center_horizontal" >

            <RelativeLayout
                android:layout_width="65dp"
                android:layout_height="70dp" >

                <ImageView
                    android:id="@+id/user_image"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_alignWithParentIfMissing="false"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:layout_marginTop="7dp"
                    android:src="@drawable/d_bg" />

            </RelativeLayout>

            <RelativeLayout
                android:layout_width="140dp"
                android:layout_height="70dp" >

                <TextView
                    android:id="@+id/name"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="0dp"
                    android:layout_toRightOf="@id/user_image"
                    android:paddingBottom="2dip"
                    android:text="Amrinder"
                    android:textColor="#000000"
                    android:textSize="16sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/distance"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/name"
                    android:layout_marginTop="2dp"
                    android:layout_toRightOf="@id/user_image"
                    android:text="description"
                    android:textColor="#000000"
                    android:textSize="10sp" >

                </TextView>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/distance"
                    android:layout_marginTop="7dp"
                    android:orientation="horizontal" >

                    <ImageView
                        android:id="@+id/common_icon"
                        android:layout_width="26dp"
                        android:layout_height="19dp"
                        android:background="@drawable/common_icon" />

                    <TextView
                        android:id="@+id/common_number"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:text="4"
                        android:textColor="#000000"
                        android:textStyle="bold" />

                    <ImageView
                        android:id="@+id/friends_icon"
                        android:layout_width="26dp"
                        android:layout_height="19dp"
                        android:layout_marginLeft="7dp"
                        android:background="@drawable/friends_icon" />

                    <TextView
                        android:id="@+id/friends_number"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:text="5"
                        android:textColor="#000000"
                        android:textStyle="bold" />
                </LinearLayout>

                <TextView
                    android:id="@+id/nearUserInfo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:visibility="invisible" >
                </TextView>
            </RelativeLayout>

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

                <TextView
                    android:id="@+id/time_ago"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"

                    android:text="10 min ago" 
                    />

                <ImageView
                    android:id="@+id/dir_img"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/time_ago"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="23dp"
                    android:background="@drawable/say_hi_button" />

            </RelativeLayout>
        </TableRow>
    </TableLayout>
</RelativeLayout>

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
>

<ImageView
    android:id="@+id/map_bar"
    android:layout_width="fill_parent"
    android:layout_height="25dip"
    android:layout_centerInParent="false"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/map_box_bg" />


<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="25dp" >

    <TextView
        android:id="@+id/distance_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="1dp"
        android:text="X is 4 km north-east of you now"
        android:textColor="#ffffff"
        android:textStyle="bold" />

</RelativeLayout>
<FrameLayout
    android:id="@+id/frame_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="fill_parent"
    android:layout_height="150dp"
    android:layout_below="@id/map_bar"

    />
<View
        android:id="@+id/trans_img"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/trans" />         
</FrameLayout>

</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >

<ImageView
    android:id="@+id/like_bar"
    android:layout_width="fill_parent"
    android:layout_height="25dip"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/map_box_bg" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="25dp" >

    <ImageView
        android:id="@+id/like_button"
        android:layout_width="24dp"
        android:layout_height="23dp"

        android:layout_centerVertical="true"
        android:layout_marginLeft="1dp"
        android:background="@drawable/common_detail_icon" />

    <TextView
        android:id="@+id/likes_in_common"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/like_button"
        android:gravity="center_vertical"
        android:text=" 3 likes in common"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />

    </RelativeLayout>

<ImageView
    android:id="@+id/like_bg"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/like_bar"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/list_bg" />

</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >

<ImageView
    android:id="@+id/friends_bar"
    android:layout_width="fill_parent"
    android:layout_height="25dip"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/map_box_bg" />

    <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="25dp"
    android:layout_alignParentRight="true" >

    <ImageView
        android:id="@+id/friends_button"
        android:layout_width="24dp"
        android:layout_height="23dp"

        android:layout_centerVertical="true"
        android:layout_marginLeft="1dp"
        android:background="@drawable/common_friends_icon" />

    <TextView
        android:id="@+id/friends_in_common"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/friends_button"
        android:gravity="center_vertical"
        android:text=" 9 friends in common"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />

    </RelativeLayout>

<ImageView
    android:id="@+id/friends_bg"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/friends_bar"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/list_bg" />



</RelativeLayout>


<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >

<ImageView
    android:id="@+id/friends_bar"
    android:layout_width="fill_parent"
    android:layout_height="25dip"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/map_box_bg" />

    <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="25dp"
    android:layout_alignParentRight="true" >

    <ImageView
        android:id="@+id/friends_button"
        android:layout_width="24dp"
        android:layout_height="23dp"

        android:layout_centerVertical="true"
        android:layout_marginLeft="1dp"
        android:background="@drawable/common_friends_icon" />

    <TextView
        android:id="@+id/friends_in_common"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/friends_button"
        android:gravity="center_vertical"
        android:text=" 9 friends in common"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />

    </RelativeLayout>

<ImageView
    android:id="@+id/friends_bg"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/friends_bar"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/list_bg" />



</RelativeLayout>



<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp" >

<ImageView
    android:id="@+id/friends_bar"
    android:layout_width="fill_parent"
    android:layout_height="25dip"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/map_box_bg" />

    <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="25dp"
    android:layout_alignParentRight="true" >

    <ImageView
        android:id="@+id/friends_button"
        android:layout_width="24dp"
        android:layout_height="23dp"

        android:layout_centerVertical="true"
        android:layout_marginLeft="1dp"
        android:background="@drawable/common_friends_icon" />

    <TextView
        android:id="@+id/friends_in_common"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/friends_button"
        android:gravity="center_vertical"
        android:text=" 9 friends in common"
        android:textColor="#FFFFFF"
        android:textStyle="bold" />

    </RelativeLayout>

<ImageView
    android:id="@+id/friends_bg"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/friends_bar"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/list_bg" />
</RelativeLayout>
</LinearLayout>
</ScrollView>

最佳答案

您尝试使用透明颜色,而不是在 map fragment 上方使用透明图像,因为我也遇到了同样的问题,我使用这种方法解决了。

android:background="@android:color/transparent"

但从技术上讲,按照 Android 的建议,您不应在另一个滚动元素内使用滚动元素。您可以使用 Google map 静态 map API 在 ScrollView 内显示静态 map ,当您点击 ScrollView 时,您可以打开一个在新窗口中滚动的谷歌地图。

关于android - ScrollView 内的 fragment 使黑色背景闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14909686/

有关android - ScrollView 内的 fragment 使黑色背景闪烁的更多相关文章

  1. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  2. ruby-on-rails - 使用 Rmagick 或 ImageMagick 在背景上放置标题 - 2

    我有一张背景图片,我想在其中添加一个文本框。我想弄清楚如何将标题放置在其顶部的正确位置。(我使用标题是因为我需要自动换行功能)。现在,我只能让文本显示在左上角,但我需要能够手动定位它的开始位置。require'RMagick'require'Pry'includeMagicktext="Loremipsumdolorsitamet"img=ImageList.new('template001.jpg')img 最佳答案 这是使用convert的ImageMagick命令行的答案。如果你想在Rmagick中使用这个方法,你必须自己移植

  3. ruby-on-rails - 从应用程序中自定义文件夹内的命名空间自动加载 - 2

    我们目前正在为ROR3.2开发自定义cms引擎。在这个过程中,我们希望成为我们的rails应用程序中的一等公民的几个类类型起源,这意味着它们应该驻留在应用程序的app文件夹下,它是插件。目前我们有以下类型:数据源数据类型查看我在app文件夹下创建了多个目录来保存这些:应用/数据源应用/数据类型应用/View更多类型将随之而来,我有点担心应用程序文件夹被这么多目录污染。因此,我想将它们移动到一个子目录/模块中,该子目录/模块包含cms定义的所有类型。所有类都应位于MyCms命名空间内,目录布局应如下所示:应用程序/my_cms/data_source应用程序/my_cms/data_ty

  4. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  5. ruby - 如何在ruby中提取方括号内的内容 - 2

    我正在尝试提取方括号内的内容。到目前为止,我一直在使用它,它有效,但我想知道我是否可以直接在正则表达式中使用某些东西,而不是使用这个删除功能。a="Thisissuchagreatday[coolawesome]"a[/\[.*?\]/].delete('[]')#=>"coolawesome" 最佳答案 差不多。a="Thisissuchagreatday[coolawesome]"a[/\[(.*?)\]/,1]#=>"coolawesome"a[/(?"coolawesome"第一个依赖于提取组而不是完全匹配;第二个利用前瞻和

  6. ruby - block 内的实例评估 - 2

    我有一个Builder类,可让您添加到其中一个实例变量:classBuilderdefinitialize@lines=[]enddeflinesblock_given??yield(self):@linesenddefadd_line(text)@lines现在,我该如何改变它my_builder=Builder.newmy_builder.lines{|b|b.add_line"foo"b.add_line"bar"}pmy_builder.lines#=>["foo","bar"]进入这个?my_builder=Builder.newmy_builder.lines{add_li

  7. ruby - 打印一个范围内的数字 - 2

    我正在尝试使用以下代码打印1到50之间的所有数字:[1..50].each{|n|putsn}但是控制台打印[1..50]我想打印这样的东西1个2个3个4个...50 最佳答案 试试下面的代码:(1..50).each{|n|putsn}问题是您使用的是[]定界符而不是()定界符。 关于ruby-打印一个范围内的数字,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/14528573

  8. ruby-on-rails - FactoryGirl工厂特征内的序列不使用主序列计数器 - 2

    我有以下工厂:FactoryGirl.definedofactory:foodosequence(:name){|n|"Foo#{n}"}trait:ydosequence(:name){|n|"Fooy#{n}"}endendend如果我跑create:foocreate:foocreate:foo,:y我得到Foo1,Foo2,Fooy1。但我想要Foo1,Foo2,Fooy3。我怎样才能做到这一点? 最佳答案 经过smile2day'sanswer的一些提示后和thisanswer,我得出以下解决方案:FactoryGirl.

  9. ruby-on-rails - 在所有页面上使用 Prawn 的背景图像 - 2

    我在View中有这段代码prawn_document(:page_size=>"A4",:top_margin=>80,:bottom_margin=>40,:background=>"public/uploads/1.png")do|pdf|creation_date=Time.now.strftime('%d-%m-%Y')posts=@posts.eachdo|post|pdf.pad(10)dopdf.textpost.titlepdf.textpost.textendendpdf.page_count.timesdo|i|pdf.go_to_page(i+1)pdf.draw

  10. ruby - 有没有办法匹配两个双引号内的双引号? - 2

    我尝试了以下正则表达式,但它匹配所有双引号:(?>(?这是文本的示例:"[\"mycarslastnight\",\"Burger\",\"Decaf\"shirt\",\"Mocha\",\"marshmallows\",\"CoffeeMission\"]"我要匹配的模式是第2行中双引号之间的双引号 最佳答案 一般来说,我会说:不。给定一个字符串:\"Burger\"\"Decaf\"shirt\"你如何确定哪个\"是多余的(不匹配的)?这个是在Burger之后,还是在Decaf之后,还是一个在shirt之后?还是在任何这些词之

随机推荐