동일한 너비와 높이로 4 개의 단추를 수평으로 만들려고합니다. 이제 너비를 0dp로 설정하고 가중치 = "1"로 설정하면 모든 버튼이 수평으로 동일한 폭으로 흐려 지지만이 요소의 높이를 같게 설정하고이를 수행하는 방법을 알 필요가 없습니다.사각형 단추를 만들고 horizintaly 방해하는 방법
제발,이 문제를 해결하도록 도와주세요. 내 XML 레이아웃 아래
는 :
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:id="@+id/lin_layout">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="VK"
android:id="@+id/btn1"
android:layout_weight="1"
android:layout_marginRight="5dp"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="ЮД"
android:id="@+id/btn2"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="KE"
android:id="@+id/btn3"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/contact_bg"
android:id="@+id/btn4"
android:text="MI"
android:layout_weight="1" android:layout_marginLeft="5dp"/>
</LinearLayout>
그냥 부모의 LinearLayout의 높이로 DP 치수 값을 제공하고 다른 장치에 폭 알고하지 않기 때문에, 나는이 작업을 수행 할 수 – Endor
를 match_parent 각 버튼의 높이를 설정합니다. – berliozz