2017-10-15 60 views
0

我有一個用於我的片段的佈局的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> 

回答

1

在你的第一個相對佈局,嘗試刪除

android:layout_marginTop="410dp" 

並添加此

android:layout_gravity="bottom" 

原因:相對佈局佔用了ImageView的空間,因爲你已經硬編碼了相對佈局

layout_marginTop屬性
相關問題