开发者

Android: RelativeLayout

开发者 https://www.devze.com 2023-03-05 00:14 出处:网络
I want something like this: EditText Button EditText TextView EditText TextView EditText TextView EditText TextView

I want something like this:

EditText

Button

EditText TextView

EditText TextView

EditText TextView

EditText TextView

For this, I've created this code, but I only see this part:

EditText

Button

EditText TextView

What is wrong?

Code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    android:id="@+id/LinearLayout00"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <Ed开发者_Go百科itText 
    android:id="@+id/EditKereses" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="Név.."
    />
    <Button android:id="@+id/BtnKereses"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Keres"
    />
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/LinearLayout01"
    >
    <TextView 
        android:text="Név: "
        android:id="@+id/TEredmenyNev"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="2px"
        android:textColor="#FF9A00"
        android:textStyle="bold"
    />
    <TextView
        android:id="@+id/EredmenyNev"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/TEredmenyNev"
    />
</RelativeLayout>

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/LinearLayout02"
    >
    <TextView 
        android:text="Eredet: "
        android:id="@+id/TEredmenyEredet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="2px"
        android:textColor="#FF9A00"
        android:textStyle="bold"
    />
    <TextView
        android:id="@+id/EredmenyEredet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/TEredmenyEredet"
    />
</RelativeLayout>

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/LinearLayout02"
    >
    <TextView 
        android:text="Jelentés "
        android:id="@+id/TEredmenyJelentes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="2px"
        android:textColor="#FF9A00"
        android:textStyle="bold"
    />
    <TextView
        android:id="@+id/EredmenyJelentes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/TEredmenyJelentes"
    />
</RelativeLayout>

    <RelativeLayout 
        android:id="@+id/LinearLayout04"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        xmlns:android="http://schemas.android.com/apk/res/android">
        <TextView 
            android:text="Wikipédia: "
            android:id="@+id/TEredmenyWiki"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="2px"
            android:textColor="#FF9A00"
            android:textStyle="bold">
        </TextView>
        <TextView
            android:id="@+id/EredmenyWiki"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/TEredmenyWiki">
        </TextView>
    </RelativeLayout>

</LinearLayout>


You have

android:layout_height="fill_parent"

in your RelativeLayouts. Change it to

android:layout_height="wrap_content"


Instead of using a RelativeLayout, you could simply your code by just using a LinearLayout for your textviews that are right next to each other. It's as simple as just setting the orientation property to "Horizontal".

Example

<LinearLayout ... android:orientation="horizontal">
<TextView .. />
<TextView .. />
</LinearLayout>

This will result in something like this:

Texview1 Textview2

This has some other stuff needs to be added like: Layout_Width and Layout_Height . But these are small changes.

Also you could use a table layout to accomplish this, however a LinearLayout would be the easiest way to do it easily.

0

精彩评论

暂无评论...
验证码 换一张
取 消