Question
Q.1 a) Modify the following Android Studio code so that it includes a button when clicked it changes layout from relative to linear. b) Also,
Q.1
a) Modify the following Android Studio code so that it includes a button when clicked it changes layout from relative to linear.
b) Also, I need to make microphone image to be able to enlarge when clicked.
Java code : package com.example.layoutdemo;
import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.linear_layout1); }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId();
//noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; }
return super.onOptionsItemSelected(item); } }
XML code for relativelayout:
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="2dp" android:paddingRight="2dp"> android:id="@+id/cancelButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cancel" />
android:id="@+id/saveButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/cancelButton" android:text="Save" /> android:layout_width="150dp" android:layout_height="150dp" android:layout_marginTop="230dp" android:padding="4dp" android:layout_below="@id/cancelButton" android:layout_centerHorizontal="true" android:src="@android:drawable/ic_btn_speak_now" />
android:id="@+id/filter_button_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:gravity="center|bottom" android:background="@android:color/white" android:orientation="horizontal" >
android:id="@+id/filterButton" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="Filter" />
android:id="@+id/shareButton" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="Share" />
android:id="@+id/deleteButton" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="Delete" />
XML code for linearlayout: xmlns:tools="http://schemas.android.com/tools" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> android:src="@android:drawable/btn_star_big_on" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> android:layout_width="wrap_content" android:layout_height="wrap_content"/>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started