Answer the question
In order to leave comments, you need to log in
How to enlarge image on click on ImageView in Android Studio?
I am writing a calendar program in which when you click on a date marked in green, a dialog box is displayed with a holiday description (in the middle), a picture (top) and an exit button (bottom)
<?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:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dialogback"
android:background="@drawable/background"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:layout_margin="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/picture"
android:onClick="zoomup"
android:src="@drawable/new_year"
android:layout_weight="15"
tools:ignore="UsingOnClickInXml" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/title"
android:text="@string/new_year_s_day"
android:layout_weight="8"
android:padding="5dp"
android:textSize="28sp"
android:layout_marginTop="5dp" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="50">
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/description"
android:text="@string/_1_jun"
android:padding="5dp"
android:scrollbars="vertical"
android:textSize="14sp"
android:layout_marginTop="5dp"
/>
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/exit"
android:text="@string/exit"
android:background="@drawable/backgroundwhite"
android:layout_weight="5"
android:textSize="5sp"
tools:ignore="SmallSp" />
</LinearLayout>
</LinearLayout>
<?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:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dialogback"
android:background="@drawable/background"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:layout_margin="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/picture"
android:onClick="zoomup"
android:src="@drawable/new_year"
android:layout_weight="25"
tools:ignore="UsingOnClickInXml" />
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/title"
android:text="@string/new_year_s_day"
android:layout_weight="15"
android:padding="5dp"
android:textSize="28sp"
android:layout_marginTop="5dp" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="45">
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/description"
android:text="@string/_1_jun"
android:textSize="15sp"
android:padding="5dp"
android:layout_marginTop="5dp"
/>
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/exit"
android:text="@string/exit"
android:background="@drawable/backgroundwhite"
android:layout_weight="10"
android:textSize="5sp"
tools:ignore="SmallSp" />
</LinearLayout>
</LinearLayout>
package com.example.holidaycalendar2022
import android.app.ActionBar
import android.app.AlertDialog
import android.app.Dialog
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Picture
import android.graphics.drawable.ColorDrawable
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.Window
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
class January : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_january)
supportActionBar?.hide()
}
fun jan_1(view: android.view.View) {
val dialog: Dialog = Dialog(this)
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setContentView(R.layout.celebration_jan_1)
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
dialog.setCancelable(false)
val exit: TextView = dialog.findViewById(R.id.exit)
exit.setOnClickListener(View.OnClickListener {
dialog.dismiss()
})
dialog.show()
}
fun zoomup(view: View) {
val pic: ImageView = findViewById(R.id.picture)
}
}
package com.example.holidaycalendar2022
import android.accessibilityservice.GestureDescription
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import android.content.DialogInterface
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
supportActionBar?.hide()
}
fun ButtonJanuary (view: View) {
val JanuaryIntent = Intent(this, January::class.java)
startActivity(JanuaryIntent)
}
}
Answer the question
In order to leave comments, you need to log in
Android Studio, it is based on IntelliJ IDEA, only the android plugin is much more developed, because it is first made for Android Studio and then brought into IDEA
Duck which one you like better, if you wish, you can write a couple of bash scripts (there is an article on Habré about this) and use your favorite vim =)
If you need an export or directory structure from eclipse - Idea, if you want to use one environment and also have python or lua, say - Idea, if you have native C ++ code and want all in one - Eclipse. (Or wait for the CLion plugin and, again, Idea). If you are not doing anything other than Android, you are building gradle - then Android Studio.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question