Modify the following code so that it includes a button when

Modify the following code so that it includes a button when clicked it changes the layout from relative to linear.

Also, add an image that when clicked it enlarge to view better for the user.

** I couldn\'t find \"ic_btn_speak_now\" in application files I think it is located in android resources. I think you can refer to it the way it is written.

** You can replace the photo if you wish with any appropriate photo, I just need to see how it clicked an englarge.

Thanks for your help in advance.


LINEARLAYOUT:

<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
xmlns:tools=\"http://schemas.android.com/tools\"
android:orientation=\"horizontal\"
android:layout_width=\"match_parent\"
android:layout_height=\"match_parent\">
  
<ImageButton
android:src=\"@android:drawable/btn_star_big_on\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"/>

<TextView
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:text=\"@string/hello_world\" />
<Button android:text=\"Button1\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"/>
  
</LinearLayout>


RELATIVELAYOUT:

<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
xmlns:tools=\"http://schemas.android.com/tools\"
android:layout_width=\"match_parent\"
android:layout_height=\"match_parent\"
android:paddingLeft=\"2dp\"
android:paddingRight=\"2dp\">
  
<Button
android:id=\"@+id/cancelButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:text=\"Cancel\" />

<Button
android:id=\"@+id/saveButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:layout_toRightOf=\"@id/cancelButton\"
android:text=\"Save\" />
  
   <ImageView
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\"
   />

<LinearLayout
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\" >

<Button
android:id=\"@+id/filterButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"fill_parent\"
android:text=\"Filter\" />

<Button
android:id=\"@+id/shareButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"fill_parent\"
android:text=\"Share\" />

<Button
android:id=\"@+id/deleteButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"fill_parent\"
android:text=\"Delete\" />
</LinearLayout>

</RelativeLayout>

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);
}
}

r LayoutDemo Android Studio 2.2.3 Download Ele Edt VieA avigate Code Analyze Refactor Build Run Tools VOS Window Help Ca ch04-LayoutDemo Da app src main Ca res Iayout linear layout 1.xml Di app Gradle Scripts C Linear Layout zmlna: and \'\'http://schemas android coa/apt xmlnas tools \"http://achema8.android-com/tools android: orientation \'horizontal delay delay t height- match parent\'s android srca and drawable/btn star big on\" android layout width wrap tent android layout height \"wrap content layout width- wrap layout heicht- wrap android layout width- wrap tent d layout height \"wrap. tent inearlayout Design Text TODO And Monitor 0: Messages Termina Gradle build finished in 1m 12s 20ms la minute ago) layout app. main estlayoutlinear ayout 1.xml Android Studio 2.2.3 d Plugi Upd The folowing components are ready to update: Android Support Repostory, Google Repository, Google Apls Intel x86 Atom System Image Event Log Gradle Console te54 AM

Solution

LINEARLAYOUT:

<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
xmlns:tools=\"http://schemas.android.com/tools\"
android:orientation=\"horizontal\"
android:layout_width=\"match_parent\"
android:layout_height=\"match_parent\">
  
<ImageButton
android:src=\"@android:drawable/btn_star_big_on\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"/>

<TextView
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:text=\"@string/hello_world\" />
<Button android:text=\"Button1\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"/>
  
</LinearLayout>


RELATIVELAYOUT:

<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
xmlns:tools=\"http://schemas.android.com/tools\"
android:layout_width=\"match_parent\"
android:layout_height=\"match_parent\"
android:paddingLeft=\"2dp\"
android:paddingRight=\"2dp\">
  
<Button
android:id=\"@+id/cancelButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:text=\"Cancel\" />

<Button
android:id=\"@+id/saveButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"
android:layout_toRightOf=\"@id/cancelButton\"
android:text=\"Save\" />
  
<ImageView
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\"
/>

<LinearLayout
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\" >

<Button
android:id=\"@+id/filterButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"fill_parent\"
android:text=\"Filter\" />

<Button
android:id=\"@+id/shareButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"fill_parent\"
android:text=\"Share\" />

<Button
android:id=\"@+id/deleteButton\"
android:layout_width=\"wrap_content\"
android:layout_height=\"fill_parent\"
android:text=\"Delete\" />
</LinearLayout>

</RelativeLayout>

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);
}
}

Modify the following code so that it includes a button when clicked it changes the layout from relative to linear. Also, add an image that when clicked it enlar
Modify the following code so that it includes a button when clicked it changes the layout from relative to linear. Also, add an image that when clicked it enlar
Modify the following code so that it includes a button when clicked it changes the layout from relative to linear. Also, add an image that when clicked it enlar
Modify the following code so that it includes a button when clicked it changes the layout from relative to linear. Also, add an image that when clicked it enlar
Modify the following code so that it includes a button when clicked it changes the layout from relative to linear. Also, add an image that when clicked it enlar

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site