How to create below Image type of Progress ring in my Android app. I Want to show it 10 second before my whole app is loading on device. and also I want to rotate it. like window device rotate. Any Help be appreciated. I am new to Andorid.
Image :
I got the perfect answer.
Using this link I found the round progress ring.
progress_bar.gif
Then I Use this code :
animation.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/progress_bar"
android:pivotX="50%"
android:pivotY="50%" />
In My main xml file.
<RelativeLayout 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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity">
<ProgressBar
android:id="#+id/progressbar1"
android:layout_marginTop="80dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="#anim/animation"/>
</RelativeLayout>
and finally output is :
u Can use the gifView library :https://github.com/koral--/android-gif-drawable
use this is your .xml:-
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/src_anim"
/>
where src_anim is your loader gif file
Modifying the resource image of Progress Bar - this question recently has been discussed here. Check it out.
In short - you can use
custom drawable
animation-list
Both approaches allows to create progress bar like yours.
You can use this library to do it in a easier way. Furthermore, so many intuitive progressBar's type is available for you as well.
https://github.com/81813780/AVLoadingIndicatorView
Use Lottie animation.
See: https://github.com/airbnb/lottie-android
The LottieDrawable from library contains method progress(), which sets right frame if loaded image is progress image.
Related
I am having a recyclerview inside a relative layout and the app is working fine, the navigation drawer is smooth. But I added an Imageview over the recycler view so that I can hide and show based on the availability of the data. But soon as I have added the Imageview the navigation drawer becomes very slow. And when I remove the Imageview it again works smooth. The image size is just 38kb. Can someone tell me how to show empty state in an efficient way
This is my Layout with the ImageView
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.test.sample.itemHistory"
tools:showIn="#layout/app_bar_item_history"
android:background="#ffffff">
<android.support.v7.widget.RecyclerView
android:id="#+id/materialList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageViewNoItems"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/noItems" />
</RelativeLayout>
Thanks in Advance
In my case, I try to load Image (PNG File within the Project Drawable Resource Folder) to my RecycleView's ImageView as well using Picasso and I facing the same problem where the Navigation Drawer sliding animation is being slow down.
I found that the main issue is because my Image File is quite Large so the Picasso load the Full Size image into the RecycleView's ImageView which would cause the Lag.
My Solution are: (I am using KOTLIN Language)
Re-size the image using Picasso built in resize function
Without Resize (Which Cause Lag):
Picasso.get().load(R.drawable.icon).into(holder.view.ImageView)
Resized (Solve Lag Problem):
Picasso.get().load(R.drawable.icon).resize(400,400).centerCrop().into(holder.view.ImageView)
Use setImageDrawable instead of Picasso
This Method does not required to Resize the image:
holder.view.ImageView.setImageDrawable(holder.view.ImageView.context.resources.getDrawable(R.drawable.icon))
used picasso or glide library for image loading.. and also add one line in your manifest and your project become smooth as before.
<application
android:largeHeap="true">
</application>
largeHeap is used to avoid outofmemory exception while loading images.
see this Image
I want to create a new swipe down refresh progress bar. A circle and a arrow rotating inside that like Gmail app do. The sample image is shown above.
Which is called swipe down refresh, To implement this you have to use android.support.v4.widget.SwipeRefreshLayout.
The first thing we need to do is add the support library to our application’s build.gradle file.
compile 'com.android.support:support-v4:21.0.+'
Then we have to create a layout like this.
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="#+id/activity_main_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
You can find a great tutorial here with the code.
I'm using a USB connected device to run my app. In this practice app, I used an Android logo image to implement the zooming feature. When I try to change the image dimensions in the activity, it does not show the changes when the app imported into the usb device is loaded. The logo is simply zoomed to fit. But I want it to display the image with the way I see it in the Design view: http://i.imgur.com/hcaOHjW.png
I forked the code from this source to implement the zooming: http://www.c-sharpcorner.com/UploadFile/88b6e5/multi-touch-panning-pinch-zoom-image-view-in-android-using/
It does not have the double tap zoom in and out feature so let me know what I can add to implement that
And here is the code for my activity:
<RelativeLayout 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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.example.test.firstapp.Login"
android:id="#+id/activity_activity2"
android:focusable="false"
android:nestedScrollingEnabled="false">
<ImageView
android:layout_width="180dp"
android:layout_height="220dp"
android:id="#+id/botImg"
android:src="#drawable/bot"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"/>
in your java class try creating this view and then try changing the height and width parameters .inflate this view dynamically and assign parameters in the java itself dont use xml for this view .
I want to show and hide the action bar /toolbar as the Google Play store app. I am using sliding tabs on top and view pager to show the content of each tab. Here is the screenshot of Google play store app for the reference:
My layout XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout style="#style/HeaderBar"
android:id="#+id/headerbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/toolbar_no_bg"
android:id="#+id/toolbar_actionbar"/>
<com.fauzie.sample.tabsspinner.widget.SlidingTabLayout
android:background="#color/tab_background"
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/headerbar">
</android.support.v4.view.ViewPager>
</RelativeLayout>
Thanks in advance.
Have a look at this:
https://github.com/flavienlaurent/NotBoringActionBar
There's a trick involved here. You'll need to:
Wrap your layout in a list view
Add a fake header with the same height as your action bar large header
set your action bar overlay to true
Translate the real header when the list moves (i.e. when the fake header is scrolled).
It's a little bit complicated at first but once you understand it, you see how smart and obvious it all is. The link will give you all you need I hope.
I myself used that link to implement it in my own app and it works great.
Checkout this library: https://github.com/ksoichiro/Android-ObservableScrollView
this will definitely help you
Check this example to implement this with the new official Android Design Support Library:
https://github.com/chrisbanes/cheesesquare
Whenever I have Views inside a ViewGroup inside a android.support.v4.widget.DrawerLayout, Eclipse's autocomplete starts working weird. It doesn't display most of the properties
Example with DrawerLayout -> LinearLayout -> ImageView:
In the previous screenshot, you can see that I typed "android:scale..." and the IDE's intellisense isn't showing me the ImageView's android:scaleType
If I use Eclipse's Properties window for the ImageView, I can see that it is only displaying the basic properties for "View" (and not for ImageView...):
Now if the ImageView is not a descendant of the DrawerLayout and I put it somewhere else, the autocomplete works properly:
I've seen related questions such as:
Autocomplete does not work in XML files in particular hierarchy
Content Assist doesn't work in xml with support library
but they have been dead with no answers for quite a while...
Content assist doesn't work for Views (be it TextViews, EditText, Buttons...) that I add inside the DrawerLayout. It only suggests the 'basic' properties.
Does anybody know why this happens or how to fix this?
Sample layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/some_image" />
</LinearLayout>
<RelativeLayout
android:id="#+id/drawer_view"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start" >
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
Just to give some closure to this 5 months-old question, I'll quote and link to Atul O Holic's answer. Thanks to Dileep Perla for pointing me there.
When using support package Widgets this is a common scenario (a weird
one too).
Here you using, android.support.v4.widget.DrawerLayout and hence the
issue. Happened with me a lot of time.
You can also try couple of options mentioned here.
I've found that using the tag can be handy in this case. Just put your layout that is inside the drawer in a separate layout file and then include it inside the drawer layout.