gpt4 book ai didi

java - Android: fragment 重叠其他元素

转载 作者:行者123 更新时间:2023-12-01 13:49:46 26 4
gpt4 key购买 nike

我希望在我的应用程序中实现以下视觉外观,如下所示,因此圆形图像与 map 及其父面板重叠。

enter image description here

但结果却相差甚远

enter image description here

主要 fragment 代码

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity$WalkFragment">

<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<fragment
android:id="@+id/talk_panel"
android:name="com.app.fragments.TalkFragment"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>

</RelativeLayout>

底部面板源

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/talk_panel_inner"
android:orientation="vertical"
android:background="@color/talk_background"
android:layout_alignBottom="@+id/map"
android:layout_width="match_parent"
android:layout_height="180dp"
android:clickable="true">

<!-- THIS IS ELEMENT SHOULD OVERLAP ITS PARENTS -->
<LinearLayout
android:layout_marginTop="-26dp"
android:layout_marginLeft="36dp"
android:background="@drawable/ic_launcher"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="130dp"
android:clickable="true">

<ImageView
android:id="@+id/toggle_slide"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:src="@drawable/ic_arrow_up_grey"
android:clickable="true"/>

<FrameLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp">

<EditText
android:paddingLeft="10dp"
android:id="@+id/search_box"
android:fontFamily="Roboto"
android:textSize="16sp"
android:drawablePadding="10dp"
android:drawableLeft="@drawable/ic_search_icon"
android:gravity="center"
android:singleLine="true"
android:textAlignment="center"
android:hint="@string/search_places"
android:background="@drawable/text_area"
android:layout_height="40dp"
android:paddingRight="40dp"
android:layout_width="match_parent"/>

<ImageView
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical|right"
android:background="@drawable/ic_clear"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/imageView"/>

</FrameLayout>

<TextView
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/place_color"
android:textAlignment="center"
android:text="@string/loading_place_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="12dp"/>

</LinearLayout>

</FrameLayout>

我尝试过使用RelativeLayout、LinearLayout,尝试使用LinearLayout等包装 fragment talk_panel,但没有成功。

有人可以帮我吗?任何想法和建议表示赞赏。

最佳答案

弄清楚了,可能会对人们有用。因此,我将 fragment 和圆形图像包装到 RelativeLayout 中,并将圆形形状应用于我的 ImageView,并设置位置。

结果

enter image description here

页脚 fragment

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

<fragment
android:id="@+id/talk_panel"
android:name="com.app.fragments.TalkFragment"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>

<ImageView
android:background="@drawable/circle"
android:layout_marginTop="-40dp"
android:layout_marginLeft="30dp"
android:src="@drawable/ic_launcher"
android:layout_height="80dp"
android:layout_width="80dp"
android:layout_alignTop="@id/talk_panel"/>

</RelativeLayout>

@drawable/圆

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid
android:color="#FFFFFFFF"/>

<size
android:width="160dp"
android:height="160dp"/>
</shape>

关于java - Android: fragment 重叠其他元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20054828/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com