klinker41 / android-slidingactivity Goto Github PK
View Code? Open in Web Editor NEWAndroid library which allows you to swipe down from an activity to close it.
License: Other
Android library which allows you to swipe down from an activity to close it.
License: Other
Hi, i used your library it nice but i am facing some problem in Header part
Take ur project activity
Normal Activity which contain only TextView
MenuItemActivity which contain Two EditText and Button
In Normal activity when we scroll header size is getting decreased as we go top of device
but in MenuItemActivity it not happening
Please can u help me out in these issue
How to change title color manipulate with imageView of slider?
<style name="Theme.MyGreenTheme" parent="Theme.Sliding.Light"> <item name="android:titleTextColor">@color/colorAccent</item> </style>
Thank you for the greatest lib I ever see. Just have this question
Is there any way to utilise this library or extend it to only minimise an activity on swipe down and keep as a snackbar when swiped down? I'm talking about similar functionality to youtube app where if you swipe down while watching a video, you can view other video lists while the currently playing video is minimised but not stopped.
android.view.InflateException: Binary XML file line #56: Binary XML file line #56: Error inflating class android.support.design.widget.FloatingActionButton
com.klinker.android.sliding.SlidingActivity.onCreate(SlidingActivity.java:107)
can you upload gif of lib to show us?
This can be seen in sample apk. The activity under 'Show no header sliding activity' consumes slide gesture a bit before the actual scrolling of contents takes place. May be its consuming due to header which in this activity is hidden
I want to keep one view in static position it is possible?
It has problem with google play service
when I add google play service in gradle and run the project it makes this runtime error:
Could not find class 'android.support.v7.internal.view.menu.MenuBuilder', referenced from method android.support.v7.app.AppCompatDelegateImplV7.initializePanelMenu
Could not find class 'android.support.v7.internal.view.menu.MenuBuilder', referenced from method android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu
Could not find class 'android.support.v7.internal.view.menu.MenuBuilder', referenced from method android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onPreparePanel
why is that?
I would like to use one of the various "FAB progress" libraries that allow you to either wrap an existing FAB object, such as this one or use the library directly as a FAB object, such as this one.
The SlidingActivity appears to handle the lifecycle of all its views directly (which is very convenient for the most part); I do not see a way to easily customize the FAB or any other view for that matter, other than the normal setContent()
.
I attempted the following in init()
, and it "works" in the sense that it does not crash, but it loses all the layout information of the FAB, which now appears in the top-left corner. With more work I could probably get it fairly well integrated, but it would be nicer to have a first-party solution.
val fab = findViewById(R.id.fab)
val fabParent = fab.parent as ViewGroup
fabParent.removeView(fab)
val fabWrapper = FABProgressCircle(this)
fabWrapper.addView(fab)
fabParent.addView(fabWrapper)
Is there a good way to use SlidingActivity with these kinds of extras?
Hi, nice library. I wanted to customize my image header size. How can I do that?
Very nice library. I just wondering is it possible to remove the final on onNewIntent method ? My app need to use this method to work properly. Or is there any workaround with this lib ?
Many thanks.
How to set hader image from url?
I use the latest version of the source code is 1.2.0
And in the ReadMe.md 1.1.1 or written, whether you need to update ReadMe.md?
Hello, Great work so far thx alot.
Is there anyway to load header image using Glide ?
Or Should I loaded to Bitmap than user setImage() ?
Choreographer:Skipped 173 frames! The application may be doing too much work on its main thread.
Wrong toolbar size in pre lollipop devices, look at the screenshot below.
You should add an apk for testing so that we can try if we can use it somewhere or not.
By the way great work
@klinker41 please help me .
I tried using cordinator layout as the sliding Activity content and kept FAB in that cordinator layout.
But as activity scrolls, fab also scrolling up and down.
This only happens when the app isn't active.
I did everything like in the ReadMe and I'm opening the activity from the widget via a PendingIntent.
Do I have to add sth special to the Intent, do I have to change something in the Manifest or what did I wrong?
i need this effect on a fragment....
any chances? :D
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.seasonyuu.douban.movie/me.seasonyuu.douban.movie.ui.ViewMovieActivity}: android.view.InflateException: Binary XML file line #51: Binary XML file line #18: Error inflating class com.klinker.android.sliding.TouchlessScrollView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2760)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2846)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1550)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6322)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #51: Binary XML file line #18: Error inflating class com.klinker.android.sliding.TouchlessScrollView
Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class com.klinker.android.sliding.TouchlessScrollView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:964)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.klinker.android.sliding.SlidingActivity.onCreate(SlidingActivity.java:107)
at android.app.Activity.performCreate(Activity.java:6760)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2713)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2846)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1550)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6322)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f03007c a=-1}
at android.content.res.TypedArray.getDrawable(TypedArray.java:925)
at android.view.View.<init>(View.java:4213)
at android.view.ViewGroup.<init>(ViewGroup.java:579)
at android.widget.FrameLayout.<init>(FrameLayout.java:92)
at android.widget.ScrollView.<init>(ScrollView.java:184)
at android.widget.ScrollView.<init>(ScrollView.java:180)
at com.klinker.android.sliding.TouchlessScrollView.<init>(TouchlessScrollView.java:57)
E/AndroidRuntime: at com.klinker.android.sliding.TouchlessScrollView.<init>(TouchlessScrollView.java:47)
... 29 more
compileSdkVersion 25
buildToolsVersion "25.0.3"
implementation 'com.android.support:appcompat-v7:25.4.0'
Code of Activity
class ViewMovieActivity : SlidingActivity() {
override fun init(savedInstanceState: Bundle?) {
setContent(R.layout.activity_view_movie)
}
}
Could I change the height of it ? Thanks.
Currently when we slide the SlidingActivity
to up it closes. Can we do the same on sliding down?
Similar to one in Inbox app.
I have added a fragment inside my SlidingActivity. Inside the fragment, there is a RecyclerView.
Now the recycler view is not scrolling inside the sliding activity but if I add this fragment to an AppCompatActivity, then the scrolling is working fine.
Hello! Thanks you, for your awesome work!
I use your library and i have transperent header (+fab) :(
How i can remove transparency from header?
My Activity have only 3 lines:
setTitle(app.getTitle());
setPrimaryColors(R.color.primary, R.color.primary_dark);
setContent(R.layout.activity_detail);
R.color.primary - not transperent :o
i have a recycler view below the appbar layout. The same is working in appCompatactivity but not in sliding activity. The recycler view isnt scrolling. i have also set recycler view to wrap_content
SetFab setEnabled method
When I open the activity from a RecyclerView works ok, but when I open it again with the same image drops an IllegalStateException. I add the Logcat:
Caused by: java.lang.IllegalStateException: Cannot start this animator on a detached view!
at android.view.RenderNode.addAnimator(RenderNode.java:817)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300)
at android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282)
at android.animation.RevealAnimator.<init>(RevealAnimator.java:37)
at android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:53)
at com.klinker.android.sliding.SlidingActivity.setImage(SlidingActivity.java:345)
at com.vvss.noticiasanime.DetailNewDark$2$override.onResourceReady(DetailNewDark.java:129)
at com.vvss.noticiasanime.DetailNewDark$2$override.access$dispatch(DetailNewDark.java)
at com.vvss.noticiasanime.DetailNewDark$2.onResourceReady(DetailNewDark.java:0)
at com.vvss.noticiasanime.DetailNewDark$2.onResourceReady(DetailNewDark.java:126)
at com.bumptech.glide.request.GenericRequest.onResourceReady(GenericRequest.java:525)
I add my code:
target = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
setImage(resource);
}
};
Seems that the problem is in the setImage()
:
public void setImage(Bitmap bitmap) {
photoView.setImageBitmap(bitmap);
if (isStarting) {
Palette palette = Palette.from(bitmap).generate();
setPrimaryColors(palette.getVibrantColor(DEFAULT_PRIMARY_COLOR),
palette.getDarkVibrantColor(DEFAULT_PRIMARY_DARK_COLOR));
} else {
photoViewTempBackground.setBackgroundDrawable(photoView.getBackground());
photoViewTempBackground.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final int cx = (int) photoView.getX() + photoView.getMeasuredWidth() / 2;
final int cy = (int) photoView.getY() + photoView.getMeasuredHeight() / 2;
final int finalRadius = photoView.getWidth();
Animator anim = ViewAnimationUtils.createCircularReveal(photoView, cx, cy,
0, finalRadius);
anim.setDuration(500);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
photoViewTempBackground.setVisibility(View.GONE);
}
});
anim.start();
} else {
photoView.setAlpha(0f);
photoView.animate()
.alpha(1f)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
photoView.setAlpha(1f);
photoViewTempBackground.setVisibility(View.GONE);
}
})
.start();
}
}
}
Specially in the line Animator anim = ViewAnimationUtils.createCircularReveal(photoView, cx, cy, 0, finalRadius);
. How can I solve it? Thanks.
Im using the latest android studio version and gradle and this exception happened.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.tajos.iccnotes, PID: 28374
java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN
at android.view.View.sanitizeFloatPropertyValue(View.java:18167)
at android.view.View.sanitizeFloatPropertyValue(View.java:18141)
at android.view.View.setScaleX(View.java:17494)
at com.klinker.android.sliding.MultiShrinkScroller.updateHeaderTextSizeAndMargin(MultiShrinkScroller.java:1304)
at com.klinker.android.sliding.MultiShrinkScroller.setHeaderHeight(MultiShrinkScroller.java:974)
at com.klinker.android.sliding.MultiShrinkScroller$8.run(MultiShrinkScroller.java:372)
at com.klinker.android.sliding.SchedulingUtils$1.onPreDraw(SchedulingUtils.java:39)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1102)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3310)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2200)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8999)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:996)
at android.view.Choreographer.doCallbacks(Choreographer.java:794)
at android.view.Choreographer.doFrame(Choreographer.java:729)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:981)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7814)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class com.klinker.android.sliding.TouchlessScrollView
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010000 a=-1}
how much hard is converting sliding activity into sliding fragment so we could use multiple fragment withing same activity maintaining smooth use experince.
Thanks ahead 👍
I've a webview inside the sliding activity, Initially I had height problems, since the height isn't fixed as I've set the height and width of webview to fill_parent in xml
I used the code below to solve this,
private void setupWebView() {
webView = (WebView) findViewById(R.id.webview);
webView.loadUrl(mAsset);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
final int height = webView.getMeasuredHeight();
webView.setMinimumHeight(height);
super.onPageFinished(view, url);
}
});
}
Note: I'm using offline html files for the webview
This solution works perfectly. but sometimes when the activity is called, the webview isn't scrollable this happens only sometimes and I wanna avoid it, Please help me with this
PS: I have ads in the page too, it mostly happens when the ads are being loaded at activity call
When no ads are downloaded everything runs smooth
Can't not scroll content on WebView
public void init(Bundle bundle) {
disableHeader();
setPrimaryColors(getResources().getColor(R.color.app_theme), getResources().getColor(R.color.app_theme));
mWebView = new WebView(this);
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setBuiltInZoomControls(false);
settings.setDomStorageEnabled(true);
settings.setLoadWithOverviewMode(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
mWebView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
} else {
mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
}
mWebView.setVerticalScrollBarEnabled(true);
mWebView.loadUrl("http://weixin.qq.com/agreement?lang=zh_CN");
setContent(mWebView);
}
Hi, thanks for this beautiful library :)
would you please tell me how change typeface on title?
and is it possible to disable/enable swipe down to close programmatically?
thanks in advance...
I am using content description and below content description, I am using tabLayout. I want the behavior when user scroll up the sliding activity then it should only scroll until the tabLayout comes, once tabLayout comes at the top then I want to stop the scrolling of Sliding activity
in an fab activity if i have text view with in paragraph it's slide but when i but when i using list view and
items didn't slide
After updating android support libraries to AndroidX library crashes when starting SlidingActivity. Library crashes in MultiShrinkScroller class when passing NaN to scaleX method.
Please consider updating a library to prevent apps using your library from crashing. I try fx below and app is working just fine with this change.
try { largeTextView.setScaleX(scale); largeTextView.setScaleY(scale); } catch (IllegalArgumentException ignored) {}
Thanks.
Cannot set toolbar title if header is disabled.
Hello i implemented your library in my project. The problem i am facing is :
i am not able to attach the content layout in my file.. i did everything as required but still i am not able to see the textview which is in my content_xml.
Below is my code:
Activity:
public class OtherUserProfileActivity extends SlidingActivity {
@Override
public void init(Bundle savedInstanceState) {
setTitle("Profile");
setPrimaryColors(
getResources().getColor(R.color.primary_dark),
getResources().getColor(R.color.primary)
);
setContent(R.layout.other_user_content);
setHeaderContent(R.layout.other_user_header_content);
setFab(
getResources().getColor(R.color.accent),
R.drawable.fb_like_icon,
new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(OtherUserProfileActivity.this, "FAB Clicked", Toast.LENGTH_SHORT).show();
}
}
);
}
@Override
protected void configureScroller(MultiShrinkScroller scroller) {
super.configureScroller(scroller);
scroller.setIntermediateHeaderHeightRatio(1);
}
}
other_user_content
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:textColor="#ffffff"
android:text="I think Sir you can avoid the error without turning off the Proguard. " />
other_user_header_content
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop"
android:src="@drawable/background" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.appsfreax.bestinspirationalquotes.customImageView.widget.CircleImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
android:src="@drawable/heart_on" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="My Profile"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff" />
</LinearLayout>
</FrameLayout>
Hi, i used your library and added a listview as the root element of the activity. However the listview would not scroll. Please can you help?
Hello,
what's the best way to remove an image after you've set it using setImage(...) ?
Using setImage(null) throws java.lang.RuntimeException: [...] java.lang.IllegalArgumentException: Bitmap is not valid
When I'm trying to use a RecyclerView inside a SlidingActivity I get this error:
Caused by: java.lang.ClassNotFoundException: android.view.RecyclerView
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.view.LayoutInflater.createView(LayoutInflater.java:552)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
I added library project to my project and I tried adding recyclerview gradle dependency but I get the same error.
how can I fix it?
It's possible to set auto scroll to bottom programmatically?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.