Question: Required Components: ImageView: The image that the buttons will be moving Movement Buttons: Each press should move the ImageView a certain amount, I chose to
Required Components:
ImageView: The image that the buttons will be moving
Movement Buttons: Each press should move the ImageView a certain amount, I chose to move it dp per press you can choose a different amount if you want to
Up Button: Moves the ImageView towards the top of the screen
Right Button: Moves the ImageView towards the righthand side of the screen
Down Button: Moves the ImageView towards the bottom of the screen
Left Button: Moves the ImageView towards the lefthand side of the screen
Reset Button: Resets the ImageView back to the center. For the way I implemented it I set the margins back to which should reset it back to where it started
Additional Requirements
At least one onClick method should be attached in the onCreate method with an anonymous class or a lambda expression
The Layout for the buttons and the ImageView is similar to the provided picture
A screenshot image of the completed app, looking similar to the one above. my code so far. activitymain.xml
Mainactivity.java below package com.example.androidtemplate;
import androidx.appcompat.app.AppCompatActivity;
import android.osBundle;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity
private Button button;
private View imageView;
@Override
public void onCreateBundle savedInstanceState
super.onCreatesavedInstanceState;
setContentViewRlayout.activitymain;
Button resetButton findViewByIdRidresetButton;
resetButton.setOnClickListenerview
ViewGroup.MarginLayoutParams marginParams ViewGroupMarginLayoutParams imageView.getLayoutParams;
marginParams.topMargin ;
marginParams.bottomMargin ;
marginParams.leftMargin ;
marginParams.rightMargin ;
imageView.setLayoutParamsmarginParams;
;
ImageView imageView findViewByIdRidimageView;
Button upButton findViewByIdRidupButton;
Similarly, find other buttons
upButton
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
