【问题标题】:i have created recycleview and framelayout(Mapfragment) with sameview , but framelayout always in front even through its gone我已经用 sameview 创建了 recycleview 和 framelayout(Mapfragment) ,但是 framelayout 总是在前面,即使它已经消失了
【发布时间】:2016-09-28 11:55:49
【问题描述】:

我添加了我的代码,其中包含 Framelayout 和 mapview 动态创建和 RecyclerView 另一个布局,我在 ViewPager 片段状态适配器中使用它作为 Fragment

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <RelativeLayout
        android:id="@+id/list_item"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">  
        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:elevation="5dp"
            android:id="@+id/rv"
            android:layout_above="@+id/custom_progress1"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />    
    </RelativeLayout>
    <LinearLayout
        android:id="@+id/mapLayout"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"> 
        <FrameLayout
            android:id="@+id/mapContainer"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"/> 
    </LinearLayout> 
</RelativeLayout>

【问题讨论】:

  • 亲爱的朋友,您已将父布局添加为相对布局。使用线性布局而不是使用相对布局。并且还在子布局中使用权重。这样您就可以完全按照自己的意愿查看屏幕。
  • 我已经改变了但仍然是相同的响应,最初刷卡工作正常,一旦选择地图视图并再次返回列表视图然后刷卡就死了,然后一旦我使用 viewpager 的页面条更改页面然后它工作正常.
  • 考虑为您的问题使用更精确的标题,而不是完整的句子。
  • 您是否对您的 java 代码进行了任何更改?如果是这样的话。它会正常工作。否则你可能已经做了一些改变。
  • 返回列表视图时是否需要删除片段?

标签: android android-viewpager android-framelayout mapfragment


【解决方案1】:

最好有单父布局,这有助于更快的 UI 渲染。您可以使用类似

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:elevation="5dp" />

    <FrameLayout
        android:id="@+id/mapContainer"
        android:layout_width="match_parent"
        android:layout_below="@+id/rv"
        android:layout_height="match_parent" />
</RelativeLayout>

【讨论】:

  • 我有更多的视图,比如加载微调器,所以我需要与两个父母一起做,别无他法
猜你喜欢
  • 2018-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-30
相关资源
最近更新 更多