2x3カスタムボタンのグリッドを持つプレーヤーを開発中です...ボタンはcustomplayerbutton.xmlで作成され、main.xmlの "includes"として使用されます。レイアウトに問題がある - 私のカスタムボタンはのTableRow適合しない:2x3カスタムボタングリッドレイアウトがTableRowに合わない
bad layout http://img841.imageshack.us/img841/6492/badlayout.png
私が間違っているのは何を?
customplayerbutton.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:drawable/btn_default"
android:clickable="true"
android:focusable="true"
android:longClickable="true"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2.0"
android:gravity="center"
android:text="Track67890"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2.0"
android:gravity="center"
android:text="99:99:999/99:99:999"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.1" />
</LinearLayout>
main.xml:最後に、私のLinearLayoutにTableLayoutを交換することによって、これを解決
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:longClickable="true"
android:stretchColumns="*" >
<TableRow
android:id="@+id/TableRow01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" >
<include
android:id="@+id/include01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left"
layout="@layout/customplayerbutton" />
<include
android:id="@+id/include1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="right"
layout="@layout/customplayerbutton" />
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" >
<include
android:id="@+id/include02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="@layout/customplayerbutton" />
<include
android:id="@+id/include04"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="@layout/customplayerbutton" />
</TableRow>
<TableRow
android:id="@+id/TableRow02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" >
<include
android:id="@+id/include03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="@layout/customplayerbutton" />
<include
android:id="@+id/include05"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="@layout/customplayerbutton" />
</TableRow>
</TableLayout>
を削除ライン
android:layout_gravity="left"
と第二<include>
を削除するには助けにはなりません。画面サイズが必要以上に大きい場合に影響を与えます。その場合、最初の2つのボタンがレイアウトの左右の端に重力を与えます。スクリーンショットの出力を得るには、低インチ(3.2インチ)のディスプレイが必要です。これは、アンドロイド:layout_widthが "fill_parent"ではなく "wrap_content"を含むように動作します。 – Prizoff