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
Related
I am building an app using Android Studio, and I cannot figure out how to approach this issue I am facing.
I have a recyclerview that takes up about two-thirds of the lower half of the screen. Above it are three other elements. I need those elements to disappear when the recyclerview gets scrolled, and I need the recyclerview to scale up to fill the entire screen. I have found ways to do this, but they all cause the items inside of the recyclerview to scale up as well, distorting them.
Use this implementation:-
recyclerview.addOnScrollListener(new HidingScrollListener()
{
#Override
public void onHide()
{
tabss.animate().translationY(tabss.getHeight())
.setInterpolator(new AccelerateInterpolator(2)).start();
filtershow.animate().translationY(-filtershow.getHeight())
.setInterpolator(new AccelerateInterpolator(1));
}
#Override
public void onShow()
{
tabss.animate().translationY(0).setInterpolator(new
DecelerateInterpolator(2)).start();
filtershow.animate().translationY(0).setInterpolator
(new DecelerateInterpolator(1)).start();
}
});
I'm trying to provide a fullscreen button for my camera view which is in my app. Unfortunately, during the transition, the app is showing newly calculated params before the actual animation. I mean, the new dimensions of camera view are seen for a while (blinks), then the screen is becoming black and in the end, the animation of expanding is done. This is how I do it:
fullScreenBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(isFullScreen){
TransitionManager.beginDelayedTransition(transitionsContainer);
fragmentContener.setVisibility(View.VISIBLE);
hudView.setVisibility(View.VISIBLE);
mCameraContent.setLayoutParams(params);
isFullScreen = false;
} else {
TransitionManager.beginDelayedTransition(transitionsContainer);
fragmentContener.setVisibility(View.GONE);
hudView.setVisibility(View.GONE);
mCameraContent.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
isFullScreen = true;
}
}
The fullScreenBtn is in the mCameraContent layout on the camera preview in the corner. transitionContainer is the whole activity layout. I think it is worth noting that my activity layout is divided into two equal views: baseContener and fragmentContener, the hudView is inside the baseContener below mCameraContent. They are fading out properly, the only problem is with camera preview. I was trying to add Slide() or ChangeBounds() into beginDelayedTransition method but that doesn't solve the problem. What should I do to avoid that view blinking?
I am trying to rotate an image by 360 degree using AccelerateDecelerateInterpolator. I have included the code to rotate the image in an onclickfunction of a button. When i press the button for the first time, the image rotates. However, when i press it the next time, nothing happens.
public void displaySpinResult_Spinner(View view) {
arrow.animate().rotation(360).setInterpolator(new AccelerateDecelerateInterpolator()).start();
}
This is probably because the rotation value is retained. When you specify rotation(360) for the second time, the View is already rotated by 360degrees, so nothing happens.
You can either try rotation(arrow.getRotation() + 360), or use the rotationBy() method instead.
I think this is the solution:
public void displaySpinResult_Spinner(View view) {
arrow.animate().rotation(360).setInterpolator(new AccelerateDecelerateInterpolator()).start();
arrow.animate().rotation(360).setInterpolator(new AccelerateDecelerateInterpolator()).reset();
}
I have an ImageView which is animated via startAnimation() to slide it into the screen. It is visible and enabled in the XML. When I add a Handler for a delay or an onClick event, nothing happens. When I remove the startAnimation() everything works fine. Except the animation of course.
Heres my code:
balloon.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
view.setVisibility(View.GONE);
}
});
Animation dropDown =
AnimationUtils.loadAnimation(context, R.anim.balloon_slide_down);
dropDown.setStartOffset(1500);
balloon.startAnimation(dropDown);
Any ideas why that is? I'm quite frustrated by now...
Thanks,
Ron
Your ImageView probably isn't in the location you think it is. Try setting the offset on the ImageView before the animation.
balloon.offsetTopAndBottom(offset);
//Start Animation from -offset
The animation only give you an animation that the imageview will be slided
but actually the position of the imageview isn't changed
if you want to change it you can move it using layoutparams with looping it in a UIthread
Alright... I thought it was odd that the ÌmageView should not be at the position it is shown. So I figured out that just the setVisibility() is somehow not working.
I changed my code to the following and it works:
balloon.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
((ViewGroup) balloon.getParent()).removeView(balloon);
}
});
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,