2015-11-03 158 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的东西,没有任何以前没有问过。我建议多做一些阅读(大量可用的资源)并在提问前进行搜索。