문제가 있습니다. 내 애플 리케이션에서 나는 (3-4) 버튼을 자동으로 전체 화면 크기로 확장하고 싶다. (하나의 단추가 아니라 모두 함께). 지금은 내 애플 리케이션을위한 LinearLayout를 사용하고 있습니다. 이걸로 할 수 있습니까? 나쁜 영어로 죄송합니다. 닐스Android : 화면 크기에 맞게 여러 개의 버튼을 조정하십시오.
게임 "하지 말자는 화이트 탭"의 화면이 유사하다
인사는 내가 좋아하는 것 좋아합니다 : 는
문제가 있습니다. 내 애플 리케이션에서 나는 (3-4) 버튼을 자동으로 전체 화면 크기로 확장하고 싶다. (하나의 단추가 아니라 모두 함께). 지금은 내 애플 리케이션을위한 LinearLayout를 사용하고 있습니다. 이걸로 할 수 있습니까? 나쁜 영어로 죄송합니다. 닐스Android : 화면 크기에 맞게 여러 개의 버튼을 조정하십시오.
게임 "하지 말자는 화이트 탭"의 화면이 유사하다
인사는 내가 좋아하는 것 좋아합니다 : 는
당신은 그것을 위해 무게 개념을 사용할 수 있습니다. 버튼이 모든 화면에서 동일하게 보입니다.
먼저 너비가 각각 50 인 50 개의 수평 부분과 높이가 일치하는 부모로 화면을 나눕니다. 그러면 아래 33.33로 높이 중량 각 부분 3 개 버튼을 추가
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="50"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="33.33"
android:text="Button" />
</LinearLayout>
</LinearLayout>
"1"과 같은 더 깨끗한 값으로 가중치를 대체 할 수 있습니다.이 값은 분포 계산에 사용되는 이러한 값의 실제 합계이므로 나머지는 – jcxavier
jcxavier 우리는 가중치의 분배를 위해 1 또는 100을 둘다 사용할 수 있습니다 –
추한 용액이를 달성하기 위해 가중 된 수평의 LinearLayout을 사용하면서, 수직 (동일 중량) 3 가중은 LinearLayouts를 사용하는 것 수평 효과.
은 또는 당신은 더 우아한 방법으로 비슷한 효과를 달성하기 위해의 GridView를 사용할 수 있습니다 버튼의 http://developer.android.com/guide/topics/ui/layout/gridview.html
설정 폭은 match_parent 할 수 있습니다. 그런 다음 부모에게 맞게 확장됩니다.
예 .You는 LinearLayout을 사용하여 작업 할 수 있습니다. 당신은 안드로이드 설정해야합니다 :에 layout_weight = "을"있습니다 .. buttons..it에 수평 및 수직 가중치를 부여하려면 버튼의 수를 따라
얼마나 많은 버튼을 수평 및 수직으로 가지고 있는지 말해주십시오. 그러면 LinearLayout의 코드를 여기 게시 할 것입니다 .. –
ok..i 동일한 코드가 있습니다. 위의 대답을 받아 들였습니다. 그러나 나는 당신이 원하는 정확한 대답을주기 위해 우리의 응답을 기다리고있었습니다. 어떤 방법이든 ... 제 대답은 제가 투표 할 자격이 있다고 생각합니다 :) –
사용이 XML 코드
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button"
android:layout_weight="1" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button"
android:layout_weight="1" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Button"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
세트 폭 "각 fill_parent" 버튼 –
나는 부모님과 함께 수평 모드에서 3 개의 상대적인 레이아웃을 생각하고 부모님이 당신을 도울 수 있습니다. 단지 하나의 메서드가 내 마음을 깜박입니다 – Umitk
세로 LinearLayout 내부에 같은 가중치를 갖는 3 개의 수평 지향적 인 선형 레이아웃 – user3455363