3
Good morning, you guys. I have a problem that I can not solve, I’ve fucked enough in the posts here and in the tutorials Youtube and nothing. I’m developing an android app for a project in college, but I’m not a programmer, I decided by the app to learn even.
What I need is to open an image that is in the drawable in a lightbox by clicking a button.
this is my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context="com.editoratracos.jogotracos.hd"
android:background="@drawable/fundo"
android:id="@+id/telahd"
>
<ImageButton
android:id="@+id/botaoNovo3"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="8dp"
android:background="@null"
android:onClick="chamaNovo"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:srcCompat="@drawable/novojogo"
android:layout_marginRight="70dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="70dp" />
<ImageButton
android:id="@+id/botaoComo2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="10dp"
android:background="@null"
android:onClick="chamaComo"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@drawable/comojogar"
android:layout_marginEnd="10dp" />
<ImageButton
android:id="@+id/botaoHome"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="10dp"
android:background="@null"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:srcCompat="@drawable/home"
android:onClick="chamaHome"
android:layout_marginStart="10dp" />
<ScrollView
android:layout_width="368dp"
android:layout_height="400dp"
android:layout_marginRight="0dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="1.0">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="600dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<ImageView
android:id="@+id/iconAla"
android:layout_width="60dp"
android:layout_height="60dp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="false"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ala"
android:layout_alignParentTop="true"
android:layout_toStartOf="@+id/iconAyao"
android:layout_marginEnd="10dp"/>
<ImageView
android:id="@+id/iconAyao"
android:layout_width="60dp"
android:layout_height="60dp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="false"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ayao"
android:layout_alignParentTop="true"
android:layout_toStartOf="@+id/iconBunzi"
android:layout_marginEnd="10dp"/>
<ImageView
android:id="@+id/iconBunzi"
android:layout_width="60dp"
android:layout_height="60dp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="false"
android:scaleType="fitCenter"
app:srcCompat="@drawable/bunzi"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/iconGleti"
android:layout_width="60dp"
android:layout_height="60dp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="false"
android:scaleType="fitCenter"
app:srcCompat="@drawable/gleti"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/iconBunzi"
android:layout_marginStart="10dp" />
<ImageView
android:id="@+id/iconIemanja"
android:layout_width="60dp"
android:layout_height="60dp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="false"
android:scaleType="fitCenter"
app:srcCompat="@drawable/iemanja"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/iconGleti"
android:layout_marginStart="10dp" />
<ImageView
android:id="@+id/iconMbaba"
android:layout_width="60dp"
android:layout_height="60dp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="false"
android:scaleType="fitCenter"
app:srcCompat="@drawable/mbaba"
android:layout_below="@+id/iconAla"
android:layout_alignStart="@+id/iconAla"
android:layout_marginTop="10dp" />
</RelativeLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
and that’s my class:
package com.editoratracos.jogotracos;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class hd extends AppCompatActivity {
@Override
public void onBackPressed(){
startActivity(new Intent(this, hd.class));
finishAffinity();
return;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hd);
}
public void chamaComo(View v) {setContentView(R.layout.activity_como);}
public void chamaHD(View v) {setContentView(R.layout.activity_hd);}
public void chamaNovo (View v) {setContentView(R.layout.activity_novo);}
public void chamaSobre (View v) {setContentView(R.layout.activity_sobre);}
public void chamaComecar (View v) {setContentView(R.layout.activity_comecar);}
public void chamaHome (View v) {setContentView(R.layout.activity_inicial);}
}
I’m willing to help, but still do not understand what would be a lightbox, can explain a little more? is a component? Still can not comment..
– LSA
Good afternoon, LSA! Lightbox is that image view mode where it opens on the same screen above the other elements. I found this code on github, but it is a jQuery, I don’t know how to implement in an android project: https://github.com/lokesh/lightbox2/
– Thiago Roberto de Freitas
@LSA is, changing in kids, a dialog that will display the image in larger size, being able to show all the details of it, with zoom and tauz.
– Grupo CDS Informática