DavidPizarro / AutoLabelUI

Android library to place labels next to another. If there is not enough space for the next label, it will be added in a new line.
Apache License 2.0
637 stars 107 forks source link

Adding/Removing items animation disturbs the whole layout. #4

Closed pingothedoer closed 8 years ago

pingothedoer commented 8 years ago

I have a CollapsingToolbarLayout. In container layout , i have an EditText & a Submit Button. After adding/removing one or two items using AutoLableUI on clicking Submit Button, the whole layout moves towards upward and overlaps the collapsing toolbar layout. Same Issue in another layout, where i am using Toolbar Layout along with some tabs.

DavidPizarro commented 8 years ago

Ok. I'm going to test it now. Could you send me the XML example of the error please (with CollapsingToolbarLayout for example)? Thanks!

pingothedoer commented 8 years ago

Sory for this late comment, i was not available. Here are my XMLs.

container layout : .....

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_create" />

</android.support.design.widget.CoordinatorLayout>

content_create.xml : ......

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="false">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="3dp"
    >

    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/add_tags"
        android:layout_alignParentTop="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/add_tags"
        android:textColorHint="@color/secondary_text"
        android:singleLine="true"
        android:background="@android:color/transparent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:textSize="14sp"
        android:cursorVisible="false"
        android:imeOptions="actionDone"
        android:inputType="textCapWords"
        android:layout_toStartOf="@+id/space_1"
        android:layout_toLeftOf="@+id/space_1" />

    <View
        android:id="@+id/space_1"
        android:layout_toLeftOf="@+id/imageButton"
        android:background="@color/accent"
        android:layout_width="1dp"
        android:layout_alignTop="@+id/imageButton"
        android:layout_alignBottom="@+id/imageButton"
        android:layout_height="wrap_content" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:src="@drawable/ic_arrow_drop_down_black_48dp"
        android:layout_alignTop="@+id/add_tags"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:id="@+id/imageButton" />

    <View
        android:id="@+id/space_2"
        android:layout_below="@+id/add_tags"
        android:background="@color/accent"
        android:layout_width="match_parent"
        android:layout_height="1dp" />

    <ImageView
        android:id="@+id/mainImage"
        android:layout_width="fill_parent"
        android:layout_height="300dp"
        android:layout_below="@+id/space_2"
        android:scaleType="centerCrop"
        android:src="@drawable/item_3"
        />

    <View
        android:id="@+id/space_3"
        android:layout_below="@+id/mainImage"
        android:background="@color/accent"
        android:layout_width="match_parent"
        android:layout_height="1dp" />

    <TextView
        android:id="@+id/tagsTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/primary_text"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:lineSpacingExtra="3dp"
        android:layout_below="@+id/space_3"
        android:hint="No Tags Yet"
        android:textColorHint="@color/secondary_text"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textSize="14sp"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <com.dpizarro.autolabel.library.AutoLabelUI
        android:id="@+id/label_view"
        android:layout_below="@+id/space_3"
        android:textColorHint="@color/secondary_text"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:animateLayoutChanges="false"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <View
        android:id="@+id/space_4"
        android:layout_below="@+id/label_view"
        android:background="@color/accent"
        android:layout_width="match_parent"
        android:layout_marginTop="15dp"
        android:layout_height="1dp" />

    <HorizontalScrollView
        android:id="@+id/scroller"
        android:layout_below="@+id/space_4"
        android:layout_marginTop="3dp"
        android:layout_marginBottom="3dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <LinearLayout
            android:id="@+id/myGallery"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            />
    </HorizontalScrollView>

</RelativeLayout>

</android.support.v4.widget.NestedScrollView>
DavidPizarro commented 8 years ago

Ok, I'm going to review!

pingothedoer commented 8 years ago

Sure, I am waiting,

DavidPizarro commented 8 years ago

Ok, and in the class, how do you add and remove the labels? Show me the snippet if you can please.

pingothedoer commented 8 years ago

Here is my code :

   public static AutoLabelUISettings setAutoLabelUISettings() {
           AutoLabelUISettings autoLabelUISettings =
                   new AutoLabelUISettings.Builder()
                           .withBackgroundColor(R.color.accent)
                           .withIconCross(R.drawable.cross)
                           .withMaxLabels(6)
                           .withShowCross(true)
                           .withLabelsClickables(true)
                           .withTextColor(android.R.color.white)
                           .withTextSize(R.dimen.label_title_size)
                           .build();
           return autoLabelUISettings;
       }

   /**
 * Setting Listeners on @mAutoLabel
 */
       private void setAutoLabelListeners() {
           mAutoLabel.setOnLabelsCompletedListener(new AutoLabelUI.OnLabelsCompletedListener() {
               @Override
               public void onLabelsCompleted() {
                   ToastMaker.show(CreateGifActivity.this, "No More Tag");
               }
           });

           mAutoLabel.setOnRemoveLabelListener(new AutoLabelUI.OnRemoveLabelListener() {
               @Override
               public void onRemoveLabel(View view, int position) {

                   ToastMaker.show(CreateGifActivity.this, "Label with text \" " + view.getTag() + "\" has been removed.");
                   if(mAutoLabel.getChildCount() < 1){
                       tagsTextView.setVisibility(View.VISIBLE);
                   }

               }
           });

           mAutoLabel.setOnLabelsEmptyListener(new AutoLabelUI.OnLabelsEmptyListener() {
               @Override
               public void onLabelsEmpty() {
                   ToastMaker.show(CreateGifActivity.this, "EMPTY");
               }

           });

           mAutoLabel.setOnLabelClickListener(new AutoLabelUI.OnLabelClickListener() {
               @Override
               public void onClickLabel(View v) {
                   ToastMaker.show(CreateGifActivity.this, ((Label) v).getText());
               }
           });
       }

Setting up :

    mAutoLabel = (AutoLabelUI) findViewById(R.id.label_view);
    setAutoLabelListeners();
    mAutoLabel.setSettings(setAutoLabelUISettings());

Adding Lable like :

   mAutoLabel.addLabel(newTag);
DavidPizarro commented 8 years ago

Ok, I have reviewed that and the problem seems to be the mix of Toolbar with AppBarLayout. If you remove the Toolbar or the AppBarLayout, it works perfect.

So, it seems to not be problem of the library. Why do you use both components?

pingothedoer commented 8 years ago

According to new layout design,Toolbar is supposed to be enclosed in AppBarLaout.

DavidPizarro commented 8 years ago

I can't find what is the problem. If you remove AppBarLayout or the CoordinatorLayout it works perfectly... Have you found you a solution?

pingothedoer commented 8 years ago

I had to make my own implementation. I tried to track the problem in your code but couldn't coz of time availability.

https://lh3.googleusercontent.com/9DR-ufD8esq_PHoAjRZWSkC4ybYruNx-4EOvGLxkQ_HDpNAbzGxLlapIL4y3JgaOze8FVyeCXUAXenxGkZXW3o2Wt40

DavidPizarro commented 8 years ago

Ok!

Is your application published in Google Play? Because I have decided to put in the Readme, the applications which using the library. So also they have more visibility.

If you want, you can pass me the link and add it!!

pingothedoer commented 8 years ago

As i said , m not using it anymore, i have made my own implementations.

milanPansuriya commented 8 years ago

Hey label Gravity center works for only one label is present. If i add more label than its goes in left, can suggest something for this issue.