2015-11-03 161 views
-2

嗨那裏我試圖使用這個lib到我的應用程序https://github.com/jlmd/AnimatedCircleLoadingView我希望它在該佈局的頂部,有人可以告訴我這是做完了嗎?我想加入,但它無論是覆蓋了整個屏幕或它會佔據佈局完全地加載欄覆蓋視圖

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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" 
       android:background="@color/postBg" 
       android:orientation="vertical" 
       tools:ignore="ContentDescription"> 

    <include 
     android:id="@+id/app_bar" 
     layout="@layout/app_bar"/> 

    <LinearLayout 
     android:id="@+id/newStatusHeader" 
     style="@style/newStatusHeader" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="5dp"> 

     <ImageView 
      android:id="@+id/postOwnerImage" 
      android:layout_width="60dp" 
      android:layout_height="60dp"/> 

     <LinearLayout 
      android:id="@+id/headerInfoContainer" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:layout_weight="1" 
      android:orientation="vertical" 
      android:padding="@dimen/postsItemMargin"> 

      <TextView 
       android:id="@+id/postOwnerName" 
       style="@style/postOwnerName" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceMedium"/> 

      <TextView 
       android:id="@+id/postPrivacy" 
       style="@style/postPublishDate" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/publicPrivacy"/> 
     </LinearLayout> 
    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="#E9E9E9"/> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/circle_loading_view" 
      android:layout_width="250dp" 
      android:layout_height="250dp" 
      android:layout_centerInParent="true" 
      app:mainColor="@color/primaryColor" 
      app:secondaryColor="@color/primary_high_light" 
      /> 

    <LinearLayout 
     android:id="@+id/newStatusBody" 
     style="@style/newStatusBody" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_below="@id/circle_loading_view" 
     android:layout_weight="1" 
     android:background="@color/white" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/imagePreview" 
      android:layout_width="match_parent" 
      android:layout_height="170dp" 
      android:scaleType="centerCrop" 
      android:visibility="gone"/> 



     <EditText 
      android:id="@+id/statusEdittext" 
      style="@style/statusEditText" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center_vertical" 
      android:gravity="top|left" 
      android:hint="@string/urStatus" 
      android:inputType="textMultiLine" 
      android:padding="5dp" /> 

    </LinearLayout> 
    </RelativeLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/white" 
     android:orientation="vertical"> 

     <LinearLayout 

      android:id="@+id/placePreviewLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:visibility="gone"> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="5dp" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:src="@drawable/ic_place_black"/> 

      <TextView 
       android:id="@+id/placeValuePreview" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:text="Rue Ibn ElArabi, Agadir 80000, Morocco" 
       android:textColor="@color/primary_high_light"/> 

      <TextView 
       android:id="@+id/removePlace" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:padding="4dp" 
       android:textStyle="bold" 
       android:textColor="@android:color/holo_red_light" 
       android:text="X"/> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/urlPreviewLayout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:visibility="gone" 
      > 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="5dp" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:src="@drawable/ic_insert_link_black"/> 

      <TextView 
       android:id="@+id/urlValuePreview" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:text="https://www.atouchlab.com" 
       android:textColor="@color/primary_high_light"/> 
      <TextView 
       android:id="@+id/removeLink" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:padding="4dp" 
       android:textStyle="bold" 
       android:textColor="@android:color/holo_red_light" 
       android:text="X"/> 
     </LinearLayout> 
    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="#E9E9E9"/> 

    <LinearLayout 
     android:id="@+id/newStatusFooter" 
     style="@style/newStatusFooter" 
     android:layout_width="match_parent" 
     android:layout_height="65dp"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="65dp" 
      android:layout_weight="1"> 

      <ImageButton 
       android:id="@+id/addPhoto" 
       style="@style/actionAreaBtns" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/bg_camera_button" 
       android:layout_gravity="center" /> 

      <ImageButton 
       android:id="@+id/addPlace" 
       style="@style/actionAreaBtns" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/bg_place_button" 
       android:layout_gravity="center" /> 

      <ImageButton 
       android:id="@+id/addLink" 
       style="@style/actionAreaBtns" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/bg_insert_link_button" 
       android:layout_gravity="center" /> 

      <ImageButton 
       android:id="@+id/changePrivacy" 
       style="@style/actionAreaBtns" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/bg_privacy_button" 
       android:layout_gravity="center" /> 
     </LinearLayout> 

     <ImageButton 
      android:id="@+id/sendStatus" 
      style="@style/actionAreaBtns" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/bg_publish_button" 
      android:layout_gravity="center" /> 
    </LinearLayout> 


</LinearLayout> 

LIB的.xml的一部分

<com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/circle_loading_view" 
android:layout_width="250dp" 
android:layout_height="250dp" 
android:background="@color/background" 
android:layout_centerInParent="true" 
app:mainColor="@color/main_color" 
app:secondaryColor="@color/secondary_color" 
/> 

回答

0

它要麼覆蓋了整個屏幕或將佔據佈局完全地

那是因爲你的佈局主要內容的根視圖是垂直LinearLayout的一部分,安排其所有柒在一個方向,一個堆疊在另一個之上。

如果您想讓加載指示符浮動在所有其他佈局元素(即屏幕中央)的頂部,則需要類似RelativeLayoutFrameLayout的東西。這應該成爲可能需要重疊的所有元素的根源。

我不打算複製粘貼你的整個佈局,所以想象一個簡化的版本,你有你的內容和加載指標。要定位後者對前者使用FrameLayout的頂部會是這樣的:

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

    < main content root /> 

    < loading indicator on top of main content /> 

</FrameLayout> 

當然,你可以反過來在其他一些元素包裹FrameLayout可爲屏幕裝飾像Toolbar

這是非常基本的Android的東西,沒有任何以前沒有問過。我建議多做一些閱讀(大量可用的資源)並在提問前進行搜索。