Giter Club home page Giter Club logo

android-expandicon's Introduction

Android-ExpandIcon

Android Arsenal JitPack API

Nice and simple customizable implementation of Google style up/down arrow.

image

Another nice example of using this library: Pixel Slide by hearsilent

Compatibility

This library is compatible from API 15 (Android 4.0.3).

Download

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Add the dependency

dependencies {
    implementation 'com.github.zagum:Android-ExpandIcon:1.3.0'
}

Usage

Default implementation:

    <com.github.zagum.expandicon.ExpandIconView
        android:layout_width="24dp"
        android:layout_height="24dp"/>

Fully customized implementation:

    <com.github.zagum.expandicon.ExpandIconView
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="56dp"
        app:eiv_animationDuration="300"
        app:eiv_color="#000"
        app:eiv_colorLess="#f00"
        app:eiv_colorMore="#00f"
        app:eiv_colorIntermediate="#0f0"
        app:eiv_roundedCorners="false"
        app:eiv_switchColor="true"
        app:eiv_padding="8dp"/>

Public methods:

    expandIconView.switchState();
    
    expandIconView.setState(ExpandIconView.LESS, true);
    
    expandIconView.setFraction(.3f, true);
    
    expandIconView.setAnimationDuration(2000);

See sample project for more information.

License

Copyright 2016 Evgenii Zagumennyi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-expandicon's People

Contributors

arychagov avatar johnkil avatar shusshu avatar zagum 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  avatar  avatar  avatar  avatar  avatar

android-expandicon's Issues

Padding

Could you add padding like google's icon?

Failed to implement

When trying to sync gradle this error shows.

ERROR: Failed to resolve: com.github.zagum:Android-ExpandIcon:1.2.1
Show in Project Structure dialog
Affected Modules: app

My build ;

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.example1"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

Support library version should be set to latest

Hmm, I see a commit with message "downgrade support library to 25.0.1".

I wonder if this breaks the view somehow and if yes, author should be aware, that if this library is used in some other project, gradle will by default pick the project's support lib version (unless different resolution strategy is selected), so it could potentially end up with higher version still (...and break?)

Negative Width error

XML:

    <com.github.zagum.expandicon.ExpandIconView
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
      />

Stack trace:

java.lang.IllegalArgumentException: negative width
at java.awt.BasicStroke.<init>(BasicStroke.java:194)
at java.awt.BasicStroke.<init>(BasicStroke.java:249)
at android.graphics.Paint_Delegate.getJavaStroke(Paint_Delegate.java:205)
at com.android.layoutlib.bridge.impl.GcSnapshot.createCustomGraphics(GcSnapshot.java:788)
at com.android.layoutlib.bridge.impl.GcSnapshot.drawInLayer(GcSnapshot.java:613)
at com.android.layoutlib.bridge.impl.GcSnapshot.draw(GcSnapshot.java:583)
at android.graphics.Canvas_Delegate.draw(Canvas_Delegate.java:1032)
at android.graphics.Canvas_Delegate.native_drawPath(Canvas_Delegate.java:713)
at android.graphics.Canvas.native_drawPath(Canvas.java)
at android.graphics.Canvas.drawPath(Canvas.java:1262)
at com.github.zagum.expandicon.ExpandIconView.onDraw_Original(ExpandIconView.java:199)
at com.github.zagum.expandicon.ExpandIconView.onDraw(ExpandIconView.java)
at android.view.View.draw(View.java:17068)
at android.view.View.draw(View.java:16976)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)
at android.view.View.draw(View.java:16974)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)
at android.view.View.draw(View.java:16974)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)
at android.view.View.draw(View.java:17071)
at android.widget.ScrollView.draw(ScrollView.java:1722)
at android.view.View.draw(View.java:16976)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)
at android.view.View.draw(View.java:17071)
at android.view.View.draw(View.java:16976)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)
at android.view.View.draw(View.java:16974)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)
at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)
at android.view.View.draw(View.java:17071)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:394)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:505)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:87)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136)
at com.android.tools.idea.rendering.RenderTask.lambda$renderInner$71(RenderTask.java:698)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

(startPosition.y - center.y) * Math.cos(angle))==0

This animation based on the Path to write is very good, it makes me learned a lot Thank you for your open source
Look at the code:
private void rotate(@nonnull Point startPosition, double degrees, @nonnull Point target) {
double angle = Math.toRadians(degrees);
int x = (int) (center.x + (startPosition.x - center.x) * Math.cos(angle) -
(startPosition.y - center.y) * Math.sin(angle));
int y = (int) (center.y + (startPosition.x - center.x) * Math.sin(angle) +
(startPosition.y - center.y) * Math.cos(angle));
target.set(x, y);
}
-----------------------------------------》
private void calculateArrowMetrics(int width, int height) {
final int arrowMaxWidth = (height >= width ? width : height);
if (useDefaultPadding) {
padding = (int) (PADDING_PROPORTION * arrowMaxWidth);
}
final int arrowWidth = arrowMaxWidth - 2 * padding;
float thickness = (int) (arrowWidth * THICKNESS_PROPORTION);
paint.setStrokeWidth(thickness);

center.set(width / 2, height / 2);
left.set(center.x - arrowWidth / 2, center.y);
right.set(center.x + arrowWidth / 2, center.y);

}
---------------------------------------》
rotate(left, -alpha, tempLeft);
rotate(right, alpha, tempRight);
----------------------------------------》
I feel:
left.set(center.x - arrowWidth / 2, center.y);
right.set(center.x + arrowWidth / 2, center.y);
so:
(startPosition.y - center.y) * Math.sin(angle)); In the: startPosition.y==center.y ?

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.