1 つの画面に 2 つの部分 (2 つのフラグメント: 最初のフラグメントが画面の 60% をカバーし、2 番目のフラグメントが残りを占めます) があります。最初のフラグメントでは gridview を配置し、2 番目のフラグメントでは tableLayout を作成しました。gridView に 36 個の ediText を配置しました。ダウン テーブル レイアウトでは、カスタム キーパッドを設計しました。最初のフラグメントに正確に収まるように 10 個の編集テキストを表示する必要があるため、グリッドビューの垂直スクロールバーを無効にしました。縦向きモードではエミュレーターで多少動作しますが、横向きでは動作しません。そこで、最初にフラグメントの高さを取得することにしたので、フラグメントの高さと幅を取得する方法はありますか。メジャーを取得した後でも、モードが変更されたときに現在のフラグメントに合わせて編集テキストを作成するにはどうすればよいですか? ソースを検索しましたが、明確な解決策が見つかりませんでした。以下は私のコードです。どんな提案でも大歓迎です。前もって感謝します。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/fLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/background3">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="18dp"
android:numColumns="9"
android:verticalSpacing="0dp"
android:horizontalSpacing="5dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:listSelector="@null"/>
</FrameLayout>
<FrameLayout
android:id="@+id/fLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:background="@drawable/background2">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keypad"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">
<TableRow>
<Button android:id="@+id/keypad_1"
android:text="1"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_2"
android:text="2"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_3"
android:text="3"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_4"
android:text="4"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_5"
android:text="5"
android:background="@drawable/custombutton">
</Button>
</TableRow>
<TableRow>
<Button android:id="@+id/keypad_6"
android:text="6"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_7"
android:text="7"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_8"
android:text="8"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_9"
android:text="9"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_10"
android:text="C"
android:background="@drawable/custombutton">
</Button>
</TableRow>
<TableRow>
<Button android:id="@+id/submit"
android:text="validate"
android:layout_span="5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/custombutton">
</Button>
</TableRow>
</TableLayout>
</FrameLayout>
</LinearLayout>