2017-09-01 10 views
-2

これが私のレイアウトです:明確化レイアウト

<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> 

私はImageViewのとeditTexにmatch_parentを置けば、後者は高さが画面全体を占有していない理由を私は理解していません。
代わりに私が望むように2行が得られますが、理由を理解できません

なぜですか?

+0

だから、現在、それは各 'ImageView'に' EditText'隣でお互いの下に、あなたに2 'ImageViews'を与えますか? –

+0

はい、私は高さでmatch_parentを使用するとわかりません – Ibernato933

+0

2つのLinearLayoutsが互いに下にあり、向きが両方とも水平に設定されているからです。 –

答えて

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> 
+0

thnks !!!!!!!!!!! – Ibernato933