MAD Pr14 Sumit
MAD Pr14 Sumit
MAD Pr14 Sumit
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt = findViewById(R.id.button);
img = findViewById(R.id.imageView);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
img.setImageResource(R.drawable.img);
}
});
}
}
XML Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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=".MainActivity"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/img_1" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:text="Change Image" />
</LinearLayout>
Output:
4. Write a program to display a text view using vertical scroll view
XML Code:
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Vertical ScrollView example In computer displays, filmmaking, television production, and
other kinetic
displays, scrolling is sliding text, images or video across a monitor or display, vertically or horizontally.
Scrolling ,
as such, does not change the layout of the text or pictures but moves (pans or tilts) the user's view across
what is \n
apparently a larger image that is not wholly seen.[1] A common television and movie special effect is to
scroll credits, \n
while leaving the background stationary. Scrolling may take place completely without user intervention (as
in film credits) \n
or, on an interactive device, be triggered by touchscreen or a keypress and continue without further
intervention until a \n
further user action, or be entirely controlled by input devices. Scrolling may take place in discrete increments
\n
(perhaps one or a few lines of text at a time), or continuously (smooth scrolling). Frame rate is the speed at
which an \n
entire image is redisplayed. It is related to scrolling in that changes to text and image position can only
happen as often \n
as the image can be redisplayed. When frame rate is a limiting factor, one smooth scrolling technique is to
blur images during \n
movement that would otherwise appear to jump \b
Scrolling texts, also referred to as scrolltexts or scrollers, played an important part in the birth of the
computer demo culture.
The software crackers often used their deep knowledge of computer platforms to transform the information
that accompanied their releases
into crack intros. The sole role of these intros was to scroll the text on the screen in an impressive way.
Many scrollers were plain horizontal scrollers, but demo coders also paid a lot of attention to creating new
and different types of scrolling.
The characters could, for example, continuously alter their shape, take unusual flying paths or incorporate
color effects such as raster bars.
Sometimes it makes the text nearly unreadable.
" />
</ScrollView>
</RelativeLayout>
Output: