ImageView在我的设备上不可见

ImageView在我的设备上不可见

问题描述:

我有一个用于我的片段的布局的xml代码,包含FrameLayout和RelativeLayouts,无论如何,我有一个imageview,这是在我的Android Studio设计中的相对布局中可见的,这意味着当我检查我的设计在那里,一切都是美好的,然而,当我跑我的代码,它是不可见的,我不知道为什么, 这里是我的代码:ImageView在我的设备上不可见

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:tools="http://schemas.android.com/tools" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/view_profile" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.doyousonder.android.drawer.drawer_view_profile"> 

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

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="410dp" 
    android:layout_marginBottom="10dp"> 

    <me.relex.circleindicator.CircleIndicator 
    android:id="@+id/indicator" 
    android:layout_width="match_parent" 
    android:layout_height="20dp" 
    android:layout_alignParentTop="true" /> 

    <RelativeLayout 
    android:id="@+id/UserDetailsLayout" 
    android:layout_width="match_parent" 
    android:layout_height="80dp" 
    android:background="@drawable/background_rounded_corners" 
    android:layout_below="@id/indicator" 
    android:layout_marginStart="10dp" 
    android:layout_marginEnd="10dp" 
    android:layout_marginTop="10dp" 
    android:layout_marginBottom="10dp"> 

     <com.doyousonder.android.utils.OpenSansBTextView 
      android:id="@+id/UserDetails" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5dp" 
      android:layout_marginStart="10dp" 
      android:gravity="start" 
      android:textSize="16sp" 
      android:textColor="@color/black"/> 

     <com.doyousonder.android.utils.OpenSansBTextView 
      android:id="@+id/Background" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/UserDetails" 
      android:layout_marginTop="15dp" 
      android:layout_marginStart="10dp" 
      android:gravity="start" 
      android:textSize="16sp" 
      android:textColor="@color/trolley_grey"/> 

     <com.doyousonder.android.utils.OpenSansBTextView 
      android:id="@+id/Education" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toEndOf="@id/UserDetails" 
      android:layout_marginTop="5dp" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="240dp" 
      android:gravity="end" 
      android:textColor="@color/trolley_grey" 
      android:textSize="16sp" 
      android:visibility="gone"/> 

     <de.hdodenhof.circleimageview.CircleImageView 
      android:id="@+id/editProfileGrey" 
      android:layout_width="40dp" 
      android:layout_height="40dp" 
      android:layout_toEndOf="@id/UserDetails" 
      android:layout_marginTop="15dp" 
      android:layout_marginEnd="10dp" 
      android:layout_marginStart="300dp" 
      android:gravity="end" 
      android:scaleType="centerCrop" 
      android:src="@drawable/edit_button"/> 

    </RelativeLayout> 

    <ImageView 
     android:id="@+id/arrowDown" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/UserDetailsLayout" 
     android:gravity="center" 
     android:layout_centerInParent="true" 
     android:src="@drawable/arrow_down" /> 
</RelativeLayout> 

在你的第一个相对布局,尝试删除

android:layout_marginTop="410dp" 

并添加此

android:layout_gravity="bottom" 

原因:相对布局占用了ImageView的空间,因为你已经硬编码了相对布局

layout_marginTop属性