简体   繁体   English

android:将textView放置在图像的确切位置

[英]android: placing textView in an exact location of an image

I'm building a menu for restaurant. 我正在为餐厅制作菜单。 I have this template menu image: http://img.majidonline.com/pic/313384/background3.png this is what I have to make: http://img.majidonline.com/pic/313385/background3.png here's my layout code: 我有此模板菜单图像: http : //img.majidonline.com/pic/313384/background3.png这就是我要做的: http : //img.majidonline.com/pic/313385/background3.png这是我的布局代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background3">

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"></FrameLayout>
</ScrollView>

when I add any elements to this xml, the elements sticks to the top-left corner and I can't change its location to where I want. 当我向该xml中添加任何元素时,这些元素会粘在左上角,并且无法将其位置更改为所需的位置。 I use values.xml for the prices so I can't put just a static image. 我使用values.xml作为价格,所以我不能只放置静态图像。 I'm using android studio and I'm new to android, so please help ! 我正在使用android studio,但是我是android的新手,所以请帮忙! thanks 谢谢

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
    <ImageView
    android:id="@+id/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:scaleType="fitXY"
    android:background="@drawable/background3"
    ></ImageView>
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
        <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="50dp"
        android:layout_marginTop="150dp"
        android:text="Dishes" />

        <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/textView1"
        android:layout_marginRight="50dp"
        android:text=".............." />

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/textView2"
        android:layout_marginRight="50dp"
        android:orientation="horizontal"
        android:gravity="right"
        >
            <TextView
            android:id="@+id/textView3_price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="12$" />

            <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="............" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="food" />
        </LinearLayout>

    </RelativeLayout>
</FrameLayout>

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

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