2017-09-04 7 views
0

私の誤解は何ですか?両方のレイアウトのために私はlayout_height = 140dpを持っています。しかし、なぜ彼らは異なって見える?どうすれば修正できますか? https://www.pastiebin.com/59ad4fa3d00ba https://www.pastiebin.com/59ad4fd6a20c0なぜこれらの2つのレイアウトが異なって見えるのですか?

ありがとう:ここ

は完全なXMLのです。

enter image description here

enter image description here

最初のものは次のとおりです。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="140dp" 
    android:layout_alignParentBottom="true" 
    android:orientation="horizontal"> 

    <Button 
     android:id="@+id/discount_apply" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginRight="2dp" 
     android:layout_weight="1" 
     android:background="@android:color/holo_green_dark" 
     android:paddingLeft="10dp" 
     android:text="ПРИМЕНИТЬ" /> 

    <Button 
     android:id="@+id/discount_cancel" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="2dp" 
     android:layout_weight="1" 
     android:background="@android:color/white" 
     android:paddingLeft="10dp" 
     android:text="ОТМЕНИТЬ" 
     android:textAlignment="center" 
     android:textColor="@android:color/black" /> 

</LinearLayout> 

第二には、次のとおりです。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="140dp" 
    android:layout_weight="1" 
    android:orientation="horizontal"> 

    <Button 
     android:id="@+id/CashButton" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:drawableLeft="@mipmap/cash" 
     android:paddingLeft="10dp" 
     android:layout_marginRight="2dp" 
     android:background="@android:color/holo_green_dark" 
     android:layout_weight="1" 
     android:text="НАЛИЧНЫЕ" /> 

    <Button 
     android:id="@+id/CardButton" 
     android:layout_width="match_parent" 
     android:background="@android:color/white" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="2dp" 
     android:drawableLeft="@mipmap/visa" 
     android:textColor="@android:color/black" 
     android:textAlignment="center" 
     android:layout_weight="1" 
     android:paddingLeft="10dp" 
     android:text="БАНКОВСКАЯ \n КАРТА" /> 

</LinearLayout> 
+0

体重レイアウトを使用している場合 –

+0

はい、これは実際に影響します。でも、もし私がアンドロイドを使っているのであれば、layout_heightは同じように出現すると思った。 – Andrew

答えて

2

そのこれだけのコードからではなく、第2のレイアウトに伝えることは困難静かな、 LinearLayoutにlayout_weight = 1があります。このLinearLayoutの親がorientationをverticalに設定した別のLinearLayoutである場合、このMigthは高さの設定をオーバーライドします。

+0

私はlayout_weightタグを削除し、android:layout_heightをより少ない値に設定しますか? – Andrew

+0

_weightまたは_heightのいずれかを使用し、両方を使用する必要はありません。固定高さレイアウトの場合、layout_heightを使用して_weightを削除する必要があります。 –

関連する問題