Android Studio Kotlin Dialog Box With Beautifull


Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        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:gravity="center"
        android:orientation="vertical"
        android:background="@drawable/gradientsblue"
        tools:context=".design17part15">


    <TextView
            android:id="@+id/textView6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/android_design_animation12"
            android:textColor="#FFFFFF"
            android:textSize="36sp"
            android:textStyle="bold" />

    <Button
            android:id="@+id/bntStarted"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:text="@string/get_started"
            android:textSize="30sp" />


</LinearLayout>

Android Studio Kotlin Design 

Dialog_Activity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:background="#CDDC39">
        <ImageView
                android:layout_width="66dp"
                android:layout_height="66dp"
                android:background="@drawable/bell"
                android:layout_centerInParent="true"
                android:contentDescription="@string/todo" />

    </RelativeLayout>

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/congratulations"
            android:textStyle="bold"
            android:textSize="20sp"
            android:layout_marginTop="30dp"
            android:layout_marginLeft="20dp"
            android:textColor="@color/blue"
            android:layout_marginStart="20dp" />
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="20dp"
            android:textSize="15sp"
            android:text="@string/koncet1"/>
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/ok45"
            android:layout_gravity="center"
            android:textSize="18sp"
            android:textColor="@color/blue"
            android:id="@+id/OK"/>

</LinearLayout>

Android Studio Kotlin Design 


Main_Activity.kt

package com.designapp

import android.app.Dialog
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.Window
import android.widget.Button
import android.widget.TextView
import android.widget.Toast

class design17part15 : AppCompatActivity() {

    private lateinit var btn : Button
    private lateinit var myDialog : Dialog
    private lateinit var txt : TextView

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

        btn = findViewById(R.id.bntStarted)
        btn.setOnClickListener{
            ShowDialog()
        }
    }

    private fun ShowDialog() {
        myDialog = Dialog(this)
        myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
        myDialog.setContentView(R.layout.dialog_activity)
        myDialog.setTitle("Dialog Box")

        txt = myDialog.findViewById<View>(R.id.OK) as TextView
        txt.isEnabled = true
        txt.setOnClickListener{
            Toast.makeText(applicationContext,"Thanks For Participating",
                Toast.LENGTH_SHORT).show()
            myDialog.cancel()

        }
        myDialog.show()
    }
}










Subscribe to receive free email updates:

0 Response to "Android Studio Kotlin Dialog Box With Beautifull"

Post a Comment