Image in ImageView not scaling properly - android

I have an ImageView, ther are 2 Images for a particular imageview, but the problem is when i click it (the clicked image is bigger then the previous one). So the layout gets shifted upwards, i dont want layout to move upwards, i just want image to extend upwards.
// addnews button the 1st screen
final ImageView addnewsback = (ImageView)findViewById(R.id.newslistback);
ImageView addnews = (ImageView)findViewById(R.id.newslistbtn);
addnews.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
addnewsback.setImageResource(R.drawable.bgbig);
vf.setDisplayedChild(0);
}
});
The correct view should be,

Related

Android: changing image rotation inside Recyclerview

I have an recyclerView that displays images from firebase, for some reason some of these images were rotated when uploaded to firenase.
so i would like to knew how to rotate images inside the recycler.
this is part of my code that changes orientation, but the problem is thath it only works for first item inside the recyclerview and nothing else??? so any solution.
rotateRight.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
holder.itemView.setRotation(holder.itemView.getRotation() + 90);
}
});
rotateLeft.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
holder.itemView.setRotation(holder.itemView.getRotation() + 180);
}
});
I solved it by making the rotate button inside the layout of the adapter, rather than it was inside the activity itself. now it workes well but i can't make the width after rotation to take entire screen height

How to get the touched point of an image view

Shopping Flyer A viewpager contain a firebase image.This image contain many small different images.When I touch a small image I have to display to another activity.how to proceed to achieve this ?
Use a GridLayout, with ImageView children. Use the onClickListener of the ImageView when they were added to the GridLayout to determine which image was clicked.
You don't need to know the coordinates of the image. Because the ImageView has its own space.
GridLayout gridLayout;
ArrayList<MyImage> myImages; // MyImage model should contain the image and information about the product
for (MyImage myImage : myImages) {
ImageView imageView = new ImageView(this);
imageView.setImageBitmap(myImage.getImageBitmap());
imageView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// start your details activity here
}
});
gridLayout.addView(imageView);
}

Image View OnTouchListener not working properly?

Hi I have loaded dynamically images in different position using single image view instance.
my problem is if I touch particular image second image also affected 1st I wish to find which image is touched. i want to print which image is touched. I am suffer in this task please help me.
my problem is i have only one imageview to show all images in appropriate location. I received xml file that xml contain everything like image size, image position ...etc I am loading dynamically images because i receive xml file dynamically. if i touch one image i wish to identify which image is clicked in the design that's all
This is my screen shot:
Firtly implements onTouchListener then override the method,
ImageView one = ....
ImageView two = ....
one.SetTag("ITEM ONE");
two.SetTag("ITEM TWO");
one.setOnTouchListener(this);
two.setOnToucListener(this);
#Override
public boolean onTouch(View v, MotionEvent event) {
if(v == one)
{
Log.e("Touched Itemd: ",(String) v.getTag().toString());
}
if(v == two)
{
Log.e("Touched Itemd: ",(String) v.getTag().toString());
}
}

How to slide to imageView in ScrollView

I have a layout in which i have two button:
1)back
2)help
and ScollView in which i place two image Views:
1) firstImageVeiw
1) SecondImageVeiw
first image View will be displayed on front and second is placed beneath the 1st image.
Now i want that if i click on help button the the scrollView automatically slides to 2nd image view.
Any help or suggestion.
You can use scrollview's scrollTo() method
helpbutton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
yourscrollview.scrollTo(0, yourImageView.getTop());
}
});
At runtime you can get the location of every view object with
getleft()
getTop()
getRight()
getBottom()

How can draw frame by frame animation on image view, both visible simultaneously in Android?

I want to draw animation on image view and the image position is changing on run time if user successfully tap on the image then an animation is to be draw.Here is my code
public void enter() { //To enter in to animation
setBackgroundResource(R.anim.dhakkan_animation);
frameByframe_animation = (AnimationDrawable) getBackground();
frameByframe_animation.start();
frameByframe_animation.setOneShot(true);
}
#Override
public void exit() {
//when exit from Animation
frameByframe_animation.stop();
frameByframe_animation.setVisible(false, false);
}
the problem is that when animation darws my image of image view get invisible. According to my requirement i have to show both simultaneously in background an image(image of image view) and in foreground animation play.Plese help me im totally frustated.
If you want to show imageView, when your animation goes, just do it in *.xml:
<ImageView android:id=#+id/s210 ..... android:src="#drawable/s210 />

Categories

Resources