相对布局问题/android

发布于 2024-12-28 14:45:36 字数 1340 浏览 3 评论 0原文

我在创建菜单时遇到问题(不是单击菜单按钮时的菜单,而是欢迎屏幕中选择项目的菜单)。我去了 ImageView 和 TextView float (left/right) Android 并我没有解决我的问题。我想创建至少五个或六个选项以从此菜单类中进行选择。这是我的 menu.xml 文件。请让我知道我需要做什么。

问题是第一个项目出现,但第二个项目与第一个项目重叠。我在过去一个小时里一直在解决这个问题,但无法解决这个问题。

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:padding="5dp">
<TextView
    android:textSize="18dp"
    android:id="@+id/message_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="   Check Your Account" />

<ImageView
    android:src="@drawable/ic_menu_add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/icon" />

    <TextView
    android:textSize="18dp"
    android:id="@+id/message_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="   View our Site" />

<ImageView
    android:src="@drawable/ic_menu_add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

</RelativeLayout>

谢谢你。

I am having issues with creating a menu (not menu when you click menu button -- but menu as in the welcome screen to select items). I went to ImageView and TextView float (left/right) Android and I did not solve my issue. I would like to create at least five or six options to select from on this menu class. This is my menu.xml file. Please let me know what I need to do.

The issue is that the first item appears, but the second item overlaps the first item. I been picking away with this for the last hour and cannot solve this issue.

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:padding="5dp">
<TextView
    android:textSize="18dp"
    android:id="@+id/message_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="   Check Your Account" />

<ImageView
    android:src="@drawable/ic_menu_add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/icon" />

    <TextView
    android:textSize="18dp"
    android:id="@+id/message_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="   View our Site" />

<ImageView
    android:src="@drawable/ic_menu_add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

</RelativeLayout>

thannk you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱已欠费 2025-01-04 14:45:36

为什么不使用 LinearLayout (就像一个垂直布局,里面有几个水平的小布局,每个布局都有一个 TextView 和一个 ImageView)?

无论如何,如果你想使用 RelativeLayout 你应该使用 android:layout_toRightOf, android:layout_toLeftOf, android:layout_above code> 或 android:layout_below 在 xml 中放置元素。

我建议您查看 http://developer.android.com /reference/android/widget/RelativeLayout.LayoutParams.html 如果您不知道这些参数。

Why don't you use a LinearLayout (like a vertical one with severals little horizontal ones inside, each with a TextView and an ImageView) ?

Anyway, if you want to use RelativeLayout you should use something like android:layout_toRightOf, android:layout_toLeftOf, android:layout_above or android:layout_below in your xml to place your elements.

I advise you to take a look at http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html if you don't know those parameters.

风渺 2025-01-04 14:45:36

您使用RelativeLayout,但不放置相互引用的元素。

示例:

<RelativeLayout   
   xmlns:android="http://schemas.android.com/apk/res/android"   
   android:orientation="vertical"   
   android:layout_width="fill_parent"   
   android:layout_height="fill_parent"  
   >   
   <Button android:id="@+id/topBtn"   
     android:layout_width="wrap_content"   
     android:layout_height="wrap_content"   
     android:text="Top"   
     android:layout_centerHorizontal="true">  
  </Button>  

  <Button android:id="@+id/leftBtn"   
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content"   
    android:text="Left"  
    android:layout_below="@+id/topBtn"  
    android:layout_toLeftOf="@+id/topBtn">  
  </Button> 
</RelativeLayout>

http://developer.android.com/reference/android/widget/RelativeLayout .html

You use a RelativeLayout but you don't place elements with reference to each other.

Example :

<RelativeLayout   
   xmlns:android="http://schemas.android.com/apk/res/android"   
   android:orientation="vertical"   
   android:layout_width="fill_parent"   
   android:layout_height="fill_parent"  
   >   
   <Button android:id="@+id/topBtn"   
     android:layout_width="wrap_content"   
     android:layout_height="wrap_content"   
     android:text="Top"   
     android:layout_centerHorizontal="true">  
  </Button>  

  <Button android:id="@+id/leftBtn"   
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content"   
    android:text="Left"  
    android:layout_below="@+id/topBtn"  
    android:layout_toLeftOf="@+id/topBtn">  
  </Button> 
</RelativeLayout>

http://developer.android.com/reference/android/widget/RelativeLayout.html

已下线请稍等 2025-01-04 14:45:36

线性布局会更好。

尝试一下并告诉我这是否是您所需要的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:padding="5dp"
 android:orientation="vertical"
 >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/message_view"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="   Check Your Account"
            android:textSize="18dp" />
        <ImageView
            android:id="@+id/icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_menu_add" android:layout_gravity="center_horizontal"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:id="@+id/message_view"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="   View our Site"
            android:textSize="18dp" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_menu_add" android:layout_gravity="center_horizontal"/>
    </LinearLayout>

</LinearLayout>

A Linear Layout would be better.

Try this and tell me if this is what you needed:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:padding="5dp"
 android:orientation="vertical"
 >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/message_view"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="   Check Your Account"
            android:textSize="18dp" />
        <ImageView
            android:id="@+id/icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_menu_add" android:layout_gravity="center_horizontal"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:id="@+id/message_view"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="   View our Site"
            android:textSize="18dp" />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_menu_add" android:layout_gravity="center_horizontal"/>
    </LinearLayout>

</LinearLayout>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文