如何在android中获得以下布局

如何在android中获得以下布局,android,layout,Android,Layout,我试图在android中获得以下布局: 在空白处我有一个图像视图。我的图像将一直延伸到屏幕底部,在那里我有两个按钮。 我试过这个: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fi

我试图在android中获得以下布局:

在空白处我有一个图像视图。我的图像将一直延伸到屏幕底部,在那里我有两个按钮。 我试过这个:

<?xml version="1.0" encoding="utf-8"?>
<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>

但不幸的是,我的屏幕如下所示:


那么我该如何实现这一点呢?感谢您尝试为带有按钮的线性布局添加android:layout\u gravity=“bottom”。

在相对布局中,将imageView放置在顶部,然后使用align\u parentLeft=true和align\u parentRight=true将这些按钮与layout\u Lower=“imageView的id”对齐。试试这个,让我知道…


    < ?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>

首先在android项目中创建一个xml菜单文件作为mainmenu.xml。然后通过这个代码

<?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>

我用过这个。除了我用ScrollView代替LinearLayout,用webView代替Button之外。它对me@george这种方法现在有效吗?如果没有,它不应该是被接受的答案,因为这通常会阻止其他用户回答。Almoust有效。我做了一些更改,但最接近事实:)我尝试过,很明显图像不会在整个屏幕上拉伸…:Pset layout\u width=“fill\u parent”在imageview中。我做了…问题在于高度!!!如果我放置layout\u height=“fill\u parent”,那么我将看不到按钮!是的,它看起来是这样的:现在告诉我应该怎么做才能让imageview下降?很抱歉,我没有理解你的观点。现在,你想用imageview或按钮做什么?你想给一些空间还是什么?请解释……以后,请不要打开两个答案。相反,使用答案左下角的
edit
按钮编辑原始答案。
<?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>
@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);
}