简体   繁体   English

简单的XML Android布局问题:按钮显示在界面底部

[英]Simple XML Android layout issue : The buttons are appearing at bottom of the interface

How can I modify the main.xml so the buttons appear immediately below the ImageView object? 如何修改main.xml,使按钮立即出现在ImageView对象的下面?

thanks a lot, world-class experts on Stack Overflow!! 非常感谢世界一流的Stack Overflow专家!!

here is my main.xml 这是我的main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitStart"
        android:src="@drawable/genie" />

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:scaleType="fitStart"
    android:layout_width="wrap_content"
    android:layout_gravity = "center"
    android:layout_height="wrap_content"
    >
<Button android:text="RWD" android:id="@+id/b1" android:layout_width="60dp" android:layout_height="60dp"></Button>
<Button android:text="PLAY " android:id="@+id/b2" android:layout_width="60dp" android:layout_height="60dp"></Button>
<Button android:text="FWD" android:id="@+id/b3" android:layout_width="80dp" android:layout_height="60dp"></Button>
<Button android:text="LIST" android:id="@+id/b4" android:layout_width="60dp" android:layout_height="60dp"></Button>
<Button android:text="RWD" android:id="@+id/b5" android:layout_width="60dp" android:layout_height="60dp"></Button>

        </LinearLayout>


</LinearLayout>

Use a RelativeLayout instead of LinearLayout. 使用RelativeLayout而不是LinearLayout。 In a relativelayout you can use android:below="@id/imageVIew1" to position your buttons below the imageview. 在相对布局中,您可以使用android:below =“ @ id / imageVIew1”将按钮放置在imageview下方。 Take a look at the documentation for more info, good luck 查看文档以获取更多信息,祝您好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM