T
T
troffee2015-03-24 08:25:41
Android
troffee, 2015-03-24 08:25:41

How to arrange view horizontally?

I want to arrange the view elements in a linearLayout(Horizontal) so that they are one below the other and occupy the entire width of the screen.
Here is the xml code

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Large Text"
        android:id="@+id/textView2"
        android:layout_weight="1" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Large Text"
        android:id="@+id/textView"
        android:layout_gravity="center_vertical"
        android:layout_weight="1" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText"
        android:layout_weight="1"
        android:hint="Введите "
        android:layout_marginTop="100dp" />

</LinearLayout>

Чего только не пробовал не получается. Скрин проекта ниже <img src="//habrastorage.org/files/d2a/9d8/3f9/d2a9d83f92104ed384eff849db0a678a.jpg" alt="image"/>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vitvov, 2015-03-24
@troffee

In order for the elements to be under each other, in the LinearLayout, the orientation parameter must be set to vertical. For all other elements, width = "match_parent"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question