0

上部に固定されたアクション バー、メインの UI を含む ScrollView、および画面の下部に保持したいフッターがあります (ただし、実行できません)。注: レイアウトを緑に、別の赤をデバッグ用に作成しました。

XML に関しては、ベース XML ファイルがあり、後で入力します。

base_layout.xml:

<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">

   <include layout="@layout/actionbar" />

   <ScrollView
      android:orientation="vertical"
      android:fillViewport="true"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >

      <LinearLayout
         android:id="@+id/main_menu_layout"
         android:orientation="vertical"
         android:background="#00FF00"  <!-- Note: GREEN -->
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
      </LinearLayout>
   </ScrollView>
</LinearLayout>

一部のアクティビティには PrefsBar があり、一部のアクティビティにはありません。これが、base_layout.xml ファイル内に「include layout="@layout/prefs_bar"」がない理由です (以下を参照)。 RelativeLayout を使用しないでください。

私の活動の中で私は次のことを行います:

 public void onCreate(Bundle savedInstanceState)
 {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.base_layout);

      LinearLayout emptyMainLayout = (LinearLayout)findViewById(R.id.main_menu_layout);
      LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View menuRowLayout = inflater.inflate(R.layout.tools_kvar, null);
      emptyMainLayout.addView(menuRowLayout);

tools_kvar.xml ファイルには以下が含まれます。

 <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="#FF0000" >   <!-- Note: RED -->

      <ScrollView
          android:orientation="vertical"
          android:fillViewport="true"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" >

         <TableLayout
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:stretchColumns="2">
             < .... ETC .... >
         </TableLayout>
      </ScrollView>

      <include layout="@layout/prefs_bar" />
 </LinearLayout>

最初の質問: tools_kvar.xml (RED) のメインの LinearLayout がすべての外側のレイアウトを埋めないのはなぜですか? android:layout_height="fill_parent" が設定されています!

prefs_bar.xml (上記に含まれている) は、画面の下部で修正する必要があるものです。を含む:

 <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/prefs_bar_layout"
      android:orientation="horizontal"
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"
      android:background="@color/evengrayer"
      android:gravity="bottom"
      android:layout_gravity="bottom">

      <TextView  ... ETC ...
 </LinearLayout>

現在の結果は次のとおりです。

現在の結果

どんな助けでも大歓迎です!

4

1 に答える 1

0

スクロール ビューの特定のコード ブロックで tools_kvar.xml を変更してみてください

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:fillViewport="true"
    android:orientation="vertical" >

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="2" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="test" />
    </TableLayout>
</ScrollView>
于 2011-12-30T08:54:11.723 に答える