这是我的布局:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/ic_assignment" />
<EditText
android:id="@+id/editName"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/under_line_edit"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp"
android:background="@drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/img"
android:background="@drawable/ic_person_outline" />
<EditText
android:id="@+id/editUsername"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/under_line_edit"/>
</LinearLayout>
</ScrollView>
我不明白为什么如果我将match_parent放在imageView和editTex上,后者不会占据整个屏幕的高度。
相反,我得到了两行,但我不明白为什么
为什么?
答案 0 :(得分:0)
请试试这个:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:background="@drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/ic_assignment" />
<EditText
android:id="@+id/editName"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/under_line_edit"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginTop="30dp"
android:background="@drawable/under_line_edit">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/img"
android:background="@drawable/ic_person_outline" />
<EditText
android:id="@+id/editUsername"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/under_line_edit"/>
</LinearLayout>
</ScrollView>