<FrameLayout 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"
androi" />
<FrameLayout 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"
androi" />
activity_main.xml
==============
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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.sam.web.relativelayout.MainActivity">
<ImageView
android:id="@+id/bird2Id"
android:src="@drawable/bird2"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:visibility="gone"
android:id="@+id/images2Id"
android:src="@drawable/images2"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
=======================================================
mainactivity.java
==================
package com.sam.web.relativelayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private ImageView bird2, images2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bird2=(ImageView) findViewById(R.id.bird2Id);
images2=(ImageView) findViewById(R.id.images2Id);
bird2.setOnClickListener(this);
images2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v.getId()==R.id.bird2Id){
bird2.setVisibility(View.GONE);
images2.setVisibility(View.VISIBLE);
}else if(v.getId()==R.id.images2Id){
images2.setVisibility(View.GONE);
bird2.setVisibility(View.VISIBLE);
}
}
}
thistimebd Bangladesh Live online newsportal, education, Lifestyle, Health, Photography, gif image etc.
Make your own name or company name website | contact: thistimebd24@gmail.com
Copyright © 2020-2024 News Portal in Bangladesh - THISTIMEBD.COM. ALL Rights Reserved.