2017-10-13 25 views
5

tôi có phân đoạn lồng nhau có chứa chế độ xem bản đồ, tất cả các chế độ xem được chồng chéo như tôi mong đợi ngoại trừ chế độ xem bản đồ. tôi có một recyclerview quá .. mà hiển thị theo bố cục cắt, nhưng bản đồ trong không.cách bố cục bố cục bản đồ trong máy nhắn tin chế độ xem

Ảnh chụp màn hình:

kết quả tôi nhận được là:

enter image description here

và kết quả là những gì tôi mong đợi:

enter image description here

tôi đã cố gắng với thiết lề nagative nhưng nó không làm việc cho mapview.

mã: fragment_around.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.stratafy.activities.SignupActivity"> 

    <LinearLayout 
     android:clipToPadding="false" 
     android:layout_marginTop="160dp" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/viewpager" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 


    </LinearLayout> 

    <RelativeLayout 
     android:id="@+id/background" 
     android:layout_width="match_parent" 
     android:layout_height="230dp" 
     android:background="@drawable/background_aroundme"> 

     <ProgressBar 
      android:id="@+id/mProgressbar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:visibility="gone" /> 

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

      <android.support.design.widget.TabLayout 
       android:padding="0dp" 
       android:id="@+id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_marginTop="50dp" 
       android:background="#00000000" 
       app:tabIndicatorColor="#00000000" 
       app:tabMode="fixed" 
       app:tabSelectedTextColor="@color/white" 
       app:tabTextAppearance="@style/CustomTextStyle2" 
       app:tabTextColor="@color/white" /> 

      <LinearLayout 
       android:gravity="center" 
       android:layout_gravity="center" 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

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

        <LinearLayout 
         android:orientation="vertical" 
         android:id="@+id/ll1" 
         android:gravity="center" 
         android:layout_gravity="center" 
         android:background="@color/colorAccent" 
         android:layout_width="50dp" 
         android:layout_height="2dp"></LinearLayout> 

       </LinearLayout> 

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

        <LinearLayout 
         android:visibility="gone" 
         android:orientation="vertical" 
         android:id="@+id/ll2" 
         android:layout_gravity="center" 
         android:background="@color/colorAccent" 
         android:layout_width="50dp" 
         android:layout_height="2dp"></LinearLayout> 

       </LinearLayout> 

      </LinearLayout> 

     </LinearLayout> 

    </RelativeLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="65dp" 
     android:layout_below="@id/background" 
     android:layout_marginTop="-90dp" 
     android:orientation="vertical"> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab_filter" 
      android:src="@drawable/ic_filter" 
      app:fabSize="normal" 
      android:layout_marginRight="20dp" 
      android:layout_gravity="right" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

    </LinearLayout> 


</RelativeLayout> 

margin-top = 160 bắt đầu nơi nút nổi là .. và bản đồ của tôi là tại 240dp.

fragment_map.xml

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mapFragmentContainer" 
    android:layout_width="match_parent" 
    android:layout_marginTop="-70dp" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 


</FrameLayout> 

Trả lời

2

bố trí sử dụng cắt thay vì RelativeLayout

public class CutLayout extends FrameLayout { 
    private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 
    private Xfermode pdMode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR); 
    private Path path = new Path(); 

    public CutLayout(Context context) { 
     super(context); 
    } 

    public CutLayout(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public CutLayout(Context context, AttributeSet attrs, int defStyleAttr) { 
     super(context, attrs, defStyleAttr); 
    } 

    @TargetApi(Build.VERSION_CODES.LOLLIPOP) 
    public CutLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 
     super(context, attrs, defStyleAttr, defStyleRes); 
    } 

    @Override 
    protected void dispatchDraw(Canvas canvas) { 
     int saveCount = canvas.saveLayer(0, 0, getWidth(), getHeight(), null, Canvas.ALL_SAVE_FLAG); 
     super.dispatchDraw(canvas); 

     paint.setXfermode(pdMode); 
     path.reset(); 

     path.moveTo(0, getHeight()); 
     path.lineTo(getWidth(), getHeight()); 
     path.lineTo(getWidth(), getHeight() - TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, getResources().getDisplayMetrics())); 
     path.close(); 
     canvas.drawPath(path, paint); 

     canvas.restoreToCount(saveCount); 
     paint.setXfermode(null); 
    } } 

và trong file xml

<com.helper.CutLayout 
     android:id="@+id/background" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <ImageView 
      android:scaleType="fitXY" 
      android:src="@drawable/aroundme" 
      android:layout_width="match_parent" 
      android:layout_height="230dp" /> 
</com.helper.CutLayout> 
Các vấn đề liên quan