내 애플 리케이션 디자인에서 테이블을 사용하고 싶지만 안드로이드의 XML 레이아웃에서 HTML과 달리 퍼센트를 사용하여 무언가의 너비를 설정할 수는 없다. Google에서 보면 내게 가치가 100까지 추가되는 한 동일한 기능에 대해 'layout_weight'를 사용할 수있는 것처럼 보입니다.이 질문의 정보 (http://stackoverflow.com/questions/3629331/android-trying-to -understand-androidlayout-weight) 내 레이아웃을 썼는데 제대로 작동하는 것 같았습니다. 나는이 레이아웃에 버튼을 추가 할 때 그러나이 같은 여기에 본 나누기 http://i.imgur.com/rCjKk.png안드로이드에서 "layout_weight"이해하기
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:id="@+id/tablerow1"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="10">
</TableRow>
<TableRow
android:id="@+id/tablerow2"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="80">
</TableRow>
<TableRow
android:id="@+id/tablerow3"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="10">
<TableRow
android:id="@+id/tablerow4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="50">
</TableRow>
<TableRow
android:id="@+id/tablerow5"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="50">
</TableRow>
</TableRow>
</TableLayout>
</LinearLayout>
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:id="@+id/tablerow1"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="10">
</TableRow>
<TableRow
android:id="@+id/tablerow2"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="80">
</TableRow>
<TableRow
android:id="@+id/tablerow3"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="10">
<TableRow
android:id="@+id/tablerow4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="50">
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Speak">
</Button>
</TableRow>
<TableRow
android:id="@+id/tablerow5"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="50">
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Listen">
</Button>
</TableRow>
</TableRow>
</TableLayout>
</LinearLayout>
이 사람이 나에게 http://i.imgur.com/sKxbv.png 설명 할 수 여기에
는 & 같은 XML 파일을 모습입니다 왜 이래? 나는 단순히 10 %, 80 %, 10 %에서 3 개의 행을, 그리고 나서 마지막 행의 너비의 50 %를 차지하기를 원합니다.
하단의 버튼 만 원하십니까? 아니면 특별히 전체 화면의 10pcs가되어야합니까? –