일반 Buttons와 ImageButton을 같은 layout_weight
으로 설정하려고하면 LinearLayout에서 이상한 동작이 나타납니다. 이미지 버튼의 android:src
리소스는 극도로 작으며 문제없이 ImageButton 내부에 잘 들어 맞습니다. 너비가 동일해야하지만, 어떤 이유로 ImageButton의 너비는 일반 버튼의 나머지 크기의 약 2/3입니다. ImageButton의 layout_weight
에 10을 곱하면 크기에 훨씬 가깝지만 왜 작동하지 않습니까?Android ImageButton 및 Button의 layout_weight가 다른 너비로 이어지는 이유는 무엇입니까?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1">
<Button
android:id="@+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/clear"/>
<Button
android:id="@+id/left_paren"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/left_paren"/>
<Button
android:id="@+id/right_paren"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/right_paren"/>
<ImageButton
android:id="@+id/backspace"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:contentDescription="@string/backspace"
android:src="@drawable/backspace"/>
</LinearLayout>
언제나 생각합니다. layout_width = "0dp". 안드로이드 대신 : layout_width = "wrap_content". layout_weight를 사용할 때마다. –
http://stackoverflow.com/a/41451132/2219600 – amalBit