Android EditText will not take up the remaining space

In my Android app, I have a tab Activity. On one of the tabs, I have two TextViewand two EditTexts.

The first EditTextis just one line, and that's great. However, I want the other EditText, android:id="@+id/paste_code", took the remaining space, but no matter what I do with it, it will show only one line. I do not want to manually set the number of lines, since the number that will correspond on the screen depends on your device.

Here is the relevant code. It is nested inside all the necessary components for the tab Activity.

<ScrollView
    android:id="@+id/basicTab"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:layout_weight="1" >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Paste title"
            android:layout_weight="0" />
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="@string/paste_title_hint"
            android:id="@+id/paste_title"
            android:lines="1"
            android:gravity="top|left"
            android:layout_weight="0" />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Paste text"
            android:layout_weight="0" />
        <EditText
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:hint="@string/paste_hint"
            android:id="@+id/paste_code"
            android:gravity="top|left"
            android:layout_weight="1" />
    </LinearLayout>
</ScrollView>
+3
source share
2 answers

, , :

-, Android :

http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/

, ScrollView android:fillViewport="true".

- , , :

  • ScrollView (, LinearLayout) layout_height="wrap_content"
  • (), , layout_height="wrap_content"
  • , , layout_weight="1.0"

minLines="3" , , , / .

+9

, , ScrollView. ScrollView . , ScrollView LinearLayout, EditText , . , ScrollViews , , android: layout_height. , . RelativeLayout layout_above layout_below, , , . , , , ... - , ScrollView ?

0

Source: https://habr.com/ru/post/1745365/


All Articles