How do I obtain the following layout in android
I'm trying to obtain the following layout in android: http://i54.tinypic.com/iz8enk.png
Where in the white space I'm having an imageview.My Image will stretch until the bottom of the screen where I have 2 buttons. I tried with this:
<?xml version="1.0" encoding="utf-8"?>开发者_JS百科;
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:id="@+id/myPic"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/lay"
android:background="#000000">
<Button
android:text="Retake Photo"
android:id="@+id/back"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</Button>
<Button
android:text="Confirm Photo"
android:id="@+id/confirm"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="98dip" >
</Button>
</LinearLayout>
</LinearLayout>
But unfortunately my screen looks like this: http://i53.tinypic.com/291i6id.png.
So how do I achieve that?Thanks
< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/introLayout" >
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height = "fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
android:scrollbars="none"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:id="@+id/myPic"
/>
<RelativeLayout android:layout_width="fill_parent" android:layout_marginTop="20dp" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom" android:layout_marginBottom="10dp">
<Button
android:layout_width="153dp"
android:layout_height="wrap_content"
android:text="button1"
android:layout_alignParentLeft="true"
></Button>
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="button2"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
></Button>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
In relative layout place the imageView on top and then those buttons should be placed using align_parentLeft = true and align_parentRight = true with layout_below = "id of imageview". Try this and let me know...
First Create an xml menu file as mainmenu.xml in your android project. and past this code
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/exit" android:title="Exit"
android:menuCategory="container" android:icon="@drawable/ic_menu_exit" />
<item android:id="@+id/update" android:icon="@drawable/ic_menu_update"
android:title="Update"></item>
</menu>
Also past this code below to your java code
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater infMenu = getMenuInflater();
infMenu.inflate(R.menu.mainmenu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.exit) {
UninAndroSMSActivity.this.finish();
}
if (item.getItemId() == R.id.update) {
startActivity(new Intent(UninAndroSMSActivity.this,
UninAndroSMSActivity.class));
}
return super.onOptionsItemSelected(item);
}
Try adding android:layout_gravity="bottom"
for the LinearLayout with the buttons.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/exit"
android:title="Exit"
android:menuCategory="container"
android:icon="@drawable/ic_menu_exit" />
<item android:id="@+id/update"
android:icon="@drawable/ic_menu_update"
android:title="Update" />
</menu>
精彩评论