Skip to main content
 

How to make image slider by view flipper in the android studio(kotlin)

Hi Guys, you have seemed professional android application which usually having image slider, So, in this, we will learn "How to make image slider by view flipper in the android studio(kotlin)".



activity_main.xml


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<LinearLayout
        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"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity"
        android:orientation="vertical">


 <ViewFlipper
            android:id="@+id/v_flipper"
            android:layout_width="match_parent"
            android:layout_height="220dp"
          />


</LinearLayout>


MainActivity.kt


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class MainActivity : AppCompatActivity() {

 lateinit var viewflipper : ViewFlipper

  override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


  viewflipper = findViewById(R.id.v_flipper)

        for(i in 0 until image.size) {
            flip_image(image[i])
        }
    }

    fun flip_image(i : Int) {
        val view = ImageView(this)
        view.setBackgroundResource(i)
        viewflipper.addView(view)
        viewflipper.setFlipInterval(3000)
        viewflipper.setAutoStart(true)
        viewflipper.setInAnimation(this , android.R.anim.slide_in_left)
        viewflipper.setOutAnimation(this , android.R.anim.slide_out_right)
    }
}





Comments

Popular posts from this blog

How to Create Calculator in Android Studio Using Kotlin

Hi Friends, calculator app is very easy to create in the android studio using Kotlin language as a language. In this article, I will write " How to Create Calculator in Android Studio Using Kotlin ".In this calculator app, I will design a beautiful user interface which you can publish in the play store. Generally, people only write about the logic of the app, but here I will write logic with an elegant user interface. So, let jump into the android studio. Let get started with calculator android app: Step 1: Create a new project in the android studio. Now, give the name of the application. Make sure you check the box of Kotlin support. Step 2: Select the API Level as per your wish. Select the Empty Activity in the project, And click next. Then, click finish and your project will be loaded. Now, for designing a beautiful User Interface. We will use Linear layout in our project. In the layout, there will be seven horizontal linear layouts. A...

How to make a 2D Game in Android Studio Using Koltin

2D Game in Android Studio Using Koltin Hello guys, There are many games in the Play Store, which are developed by the much big company. If you want to develop, that type of games, then you surely move to Unity, which is a platform to developed 3D games. But if don't want to develop 3D games, then you can try android studio to develop 2D games. I completely agree that android studio is not for game development, but if you started with game development in the android studio, it will be very easy to develop an application in the android studio. In this tutorial post, we will learn " How to make a 2D Game in Android Studio Using Koltin ".We will use kotlin language for this tutorial. Our game will look like this after development: So, Let get started with the tutorial: Create a new project in Android Studio Create an empty project in the android studio. Name your application. Then select the Kotlin support. After that, select the API l...

How to make Recyclerview + Share option + Clipboard Manager in Android Studio (Koltin)

How to make Recyclerview + Share option + Clipboard Manager in Android Studio (Koltin) : Hello guys, Welcome back to Coding Junction. In this article, we will talk about recyclerview adapter and implicit intent type share option and If I have time then we will discuss the clipboard manager otherwise we cover it in the next article. Our application will look like this : Edit the activity_main.xml Now, we will add the recyclerview in the layout file. Recyclerview is an advanced form of the listview. Nowadays we are using recyclerview for better customize and for the better user interface. First, add the recylerview in the libraries, then write the below codes in your activity_main.xml file. Remark that you want to remove the default layout from the XML file. activity_main.xml 1 2 3 4 5 6 7 8 9 10 11 <android.support.v7.widget.RecyclerView android:id= "@+id/recyclerview" xmlns:android= "http://schemas.android.com/apk/re...