Giter Club home page Giter Club logo

android-expandabletextview's People

Contributors

cliffus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-expandabletextview's Issues

Api Support >15

It is possible in the future that can withstand minimal version of the api 15?

Expands once but won't collapse

Hello,

My issue is that the button to expand the text only works on the first try. When I load the screen, I can expand the text correctly. However, when I try to collapse it, it looks like it's collapsing but then it expands again and then the button does not collapse or expand anything anymore. Running debug I can see that it is running collapse() method... It just is not correctly collapsing.

start

Expands fine here

expand

Starts to collapse but gets about halfway before expanding again. Does not work after this

failedcollapse

Duration consideration with variable lines

Assume we have a textview with variable text inside. The text can change from 3 lines or up to 20 lines.
If we set the duration as let's say 300ms, the 3 line scenario will be too slow and 20 lines maybe too fast.

Is there a way to have a method to set duration according to how many lines are in the TV?
setDurationPerLine(int)

Dynamic edittext id in android

Getting multiple edittext fields dynamically from JSON response.To save edittext data need to get id of edittext.How to get ids for edittext in android

1.1.0

Any idea when version 1.1.0 will be released? Or is the library dying off?

delay while collapsing the text

I am using down arrow and up arrow for collapse and expand. Expanding text works in sync with down arrow as this arrow is statically defined in layout file. I am facing problem while collapsing. I am using below code to change the image icon

` mExpandableTextView.setOnExpandListener(new ExpandableTextView.OnExpandListener() {
@OverRide
public void onExpand(ExpandableTextView view) {
mImageView.setImageResource(R.drawable.up_arrow);
}

        @Override
        public void onCollapse(ExpandableTextView view) {

            mImageView.setImageResource(R.drawable.down_arrow);
           
        }
    });`

but it seems drawable is updated immediately but Textview takes a time to collapse. Can you please help me on this?

Extras \n\n on expand

Normal State:
Nulla malesuada urna et bibendum imperdiet.

Expand State:
Nulla malesuada urna et bibendum imperdiet.\n\n

Android 8 issue

It doesn't work anymore on Android 8 (Oreo). TextView is auto expanded and it's not possible to collapse it. Tested on Nexus 6P device.

OvershootInterpolator issue

I have a problem with the OvershootInterpolator, the issue says:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void at.blogc.android.views.ExpandableTextView.setInterpolator(android.animation.TimeInterpolator)' on a null object reference
at com.company.jobs.jobsproject.MainActivity.onCreate(MainActivity.java:51)

And that line is this:
ETW_Perfil_Empresa.setInterpolator(new OvershootInterpolator());

Events when expand/collapse finished

In addition to onExpand/onCollapse events that fire when expand/collapse animation starts, it would be great to get onExpandFinished/onCollapseFinished events that fire when the corresponding animation finishes.

ExpandableTextview doesn't take orientation changes into account

After expanding / collapsing the ExpandableTextview and rotating the device, it sometimes happens that the calculated height of the TextView isn't correct anymore.

The solution would be that ExpandableTextview sets the height back to WRAP_CONTENT after expanding or collapsing.

Facing issue while using custom fonts.

Am not able to set the custom font to ExpandableTextView in XML it shows the font I selected but while running the app it uses the default font. Any Suggestion?

A way to cache the views after adding?

If we have different categories of ExpandablePlaceHolders and we often switch between them to load different data, caching the data for each placeholder is more efficient and quicker than removing all views, and repopulating the placeholders. What is the best way to do this here? The placeHolder.getAdapter().notifyDataSetChanged(); does not seem to work.

Odd layout with gravity="center" and ellipsize="end"

When using the ExpandableTextView with the attributes gravity="center" to center the text in combination with ellipsize="end", the collapsed layout of the last line is a bit off.

Collapsed state:

screenshot_1546085997

Expanded state:

screenshot_1546085995

<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical">

     <at.blogc.android.views.ExpandableTextView
         android:id="@+id/textViewDescription"
         style="@style/BodyNormal"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:gravity="center"
         android:ellipsize="end"
         android:lineSpacingExtra="2sp"
         android:maxLines="3"
         android:textColor="@color/blackAlpha87"
         app:animation_duration="500"
         tools:text="A look at the life of the astronaut, Neil Armstrong, and the legendary space mission that led him to become the first man to ..."/>

      <Button
         android:id="@+id/buttonViewMore"
         style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
         android:text="@string/view_more"
         android:textAppearance="@style/Button"
         android:textColor="?android:attr/colorPrimary"/>
</LinearLayout>

How to set Text Alignment Justified for the text ?

I am happy to work with this library. For now, I want to add justify alignment on the text. The text justified property will need to be kept for both status Expanded and Collapsed. how can I do it?

Attribute application@supportsRtl conflicts with application AndroidManifest

Error:Execution failed for task ':app:processProductionMinSdk21DebugManifest'.

Manifest merger failed : Attribute application@supportsRtl value=(false) from AndroidManifest.xml:16:9-36
is also present at [at.blogc:expandabletextview:1.0.2] AndroidManifest.xml:29:9-35 value=(true).
Suggestion: add 'tools:replace="android:supportsRtl"' to element at AndroidManifest.xml:10:5-172:19 to override.

toggling in the middle of an animation

Currently, if we toggle while the view is animating, nothing will happen.
In other words, the action is not cancelable until full expand/retract.

Can the toggle method support toggling while animation is in progress?

TextView not expanding or collapsing when using ExpandableTextView

Hi,

Thanks for creating this ExpandableTextView, it is exactly what I am looking to do, however, I'm not sure what I am missing because the textview is not expanding or collapsing for me.

I have the following ExpandableTextView in my layout:

<at.blogc.android.views.ExpandableTextView
                android:id="@+id/tv_JobDesc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="14sp"
                android:textColor="@color/laborswipe_darkgray"
                android:text="aasdf
                 a
                 a
                 a
                 a
                 "
                android:maxLines="5"
                android:ellipsize="end"
                android:background="@color/white"/>

I am trying to expand the ExpandableTextView in my adapter class like this:

public class JobAdapter extends ArrayAdapter<Job> {
    private final Context context;
    private final ArrayList<Job> jobs;
    private final int layoutResourceId;
    private ExpandableTextView desc = null;
    private Button expand = null;
    private boolean isExpanded = false;

    public JobAdapter(Context context, int layoutResourceId, ArrayList<Job> jobs) {
        super(context, layoutResourceId, jobs);
        this.context = context;
        this.jobs = jobs;
        this.layoutResourceId = layoutResourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder holder = null;

        LayoutInflater inflater = (LayoutInflater) context.getSystemService((Activity.LAYOUT_INFLATER_SERVICE));

        if (view == null) {
            view = inflater.inflate(layoutResourceId, parent, false);

            holder = new ViewHolder();
            holder.title = (TextView)view.findViewById(R.id.tv_jobTitle);
            //holder.description = (ExpandableTextView)view.findViewById(R.id.tv_JobDesc);
            desc = (ExpandableTextView)view.findViewById(R.id.tv_JobDesc);
            //holder.expand = (Button) view.findViewById(R.id.btn_descExpand);
            expand = (Button) view.findViewById(R.id.btn_descExpand);

            view.setTag(holder);
        } else {
            holder = (ViewHolder)view.getTag();
        }

        Job j = jobs.get(position);

        holder.title.setText(j.getJobTitle());
        //holder.description.setText(j.getDescription());
        desc.setText(j.getDescription());
        // set animation duration via code, but preferable in your layout files by using the animation_duration attribute
        desc.setAnimationDuration(1000L);

        // set interpolators for both expanding and collapsing animations
        desc.setInterpolator(new OvershootInterpolator());

        // or set them separately
        desc.setExpandInterpolator(new OvershootInterpolator());
        desc.setCollapseInterpolator(new OvershootInterpolator());

        //when user clicks the expand/collapse button, expand or collapse the description field
        holder.expand.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                System.out.println("Expanding Button Clicked!");
                desc.toggle();
                expand.setText(desc.isExpanded() ? "Collapse" : "Expand");
            }
        });

        // listen for expand / collapse events
        desc.setOnExpandListener(new ExpandableTextView.OnExpandListener() {
            @Override
            public void onExpand(final ExpandableTextView view) {
                Log.d("TextView", "ExpandableTextView expanded");
            }

            @Override
            public void onCollapse(final ExpandableTextView view) {
                Log.d("TextView", "ExpandableTextView collapsed");
            }
        });

        return view;
    }

    static class ViewHolder
    {
        TextView title;
        ExpandableTextView description;
        Button expand;
    }
}

I'm not sure what I am missing, am I not able to use the ExpandableTextView in a custom adapter?

Thanks for the help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.