2012-04-28 11 views
0

をXMLファイルに格納すると、ユーザーが項目を入力したときに行が動的に作成される4つの表レイアウトがあります。しかし、私は、各テーブルにUIの特定のスペースを与え、各テーブルにスクロールバーがあり、各テーブルにあまりにも多くのアイテムがある場合に備えています。 どうすればいいですか?この場合、アンドロイドでスクロールバーを使用するにはどうすればよいですか?

<?xml version="1.0" encoding="utf-8"?> 
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/AbsoluteLayout1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/loggedas" /> 

<Space 
    android:layout_width="58dp" 
    android:layout_height="1dp" /> 

<Space 
    android:layout_width="46dp" 
    android:layout_height="1dp" /> 

<Space 
    android:layout_width="346dp" 
    android:layout_height="1dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="51dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="23dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="50dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="10dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="82dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="69dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="66dp" /> 

<Space 
    android:layout_width="1dp" 
    android:layout_height="21dp" /> 

<Space 
    android:layout_width="60dp" 
    android:layout_height="1dp" /> 

<Space 
    android:layout_width="30dp" 
    android:layout_height="1dp" /> 

<Space 
    android:layout_width="10dp" 
    android:layout_height="1dp" /> 

<TextView 
    android:id="@+id/loggedastoedit" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="138dp" 
    android:layout_y="0dp" 
    android:text="@string/loggedas" 
    android:textColor="@color/Black" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="1dp" 
    android:layout_y="15dp" 
    android:text="@string/youneed" /> 

<TextView 
    android:id="@+id/caloriesneeded" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="66dp" 
    android:layout_y="16dp" 
    android:text="TextView" 
    android:textColor="@color/Red" /> 

<TextView 
    android:id="@+id/textView4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="146dp" 
    android:layout_y="17dp" 
    android:text="@string/caloriestextfield" /> 

<TextView 
    android:id="@+id/textView5" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="191dp" 
    android:layout_y="17dp" 
    android:text="@string/today" /> 



<TableLayout 

    android:id="@+id/breakfasttableviewing" 
    android:layout_width="344dp" 
    android:layout_height="wrap_content" 
    android:layout_x="1dp" 
    android:layout_y="62dp" > 

</TableLayout> 




<TableLayout 
    android:id="@+id/lunchtableviewing" 
    android:layout_width="335dp" 
    android:layout_height="wrap_content" 
    android:layout_x="2dp" 
    android:layout_y="135dp" > 

</TableLayout> 


<TableLayout 
    android:id="@+id/dinnertableviewing" 
    android:layout_width="346dp" 
    android:layout_height="wrap_content" 
    android:layout_x="2dp" 
    android:layout_y="210dp" > 

</TableLayout> 

<Button 
    android:id="@+id/addexercisebutton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="0dp" 
    android:layout_y="373dp" 
    android:text="@string/addexercise" /> 

<Button 
    android:id="@+id/addmealbutton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="121dp" 
    android:layout_y="373dp" 
    android:text="@string/addfood" /> 

<Button 
    android:id="@+id/newday" 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="209dp" 
    android:layout_y="373dp" 
    android:text="@string/newday" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="111dp" 
    android:layout_y="43dp" 
    android:text="@string/breakfast" 
    android:textStyle="bold" /> 

<TextView 
    android:id="@+id/textView6" 
    android:layout_width="wrap_content" 
    android:layout_height="39dp" 
    android:layout_x="120dp" 
    android:layout_y="107dp" 
    android:text="@string/lunch" 
    android:textStyle="bold" /> 

<TextView 
    android:id="@+id/textView7" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="121dp" 
    android:layout_y="184dp" 
    android:text="@string/dinner" 
    android:textStyle="bold" /> 

<TextView 
    android:id="@+id/textView8" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_x="116dp" 
    android:layout_y="265dp" 
    android:text="@string/exercise" 
    android:textStyle="bold" /> 

<TableLayout 
    android:id="@+id/exercisetableviewing" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_x="5dp" 
    android:layout_y="289dp" > 
</TableLayout> 

+0

さまざまなデバイスに予測可能な方法で表示されないため、AbsoluteLayoutsが嫌になるので、RelativeLayoutのような別のレイアウトをすべてのSpace要素なしにお勧めします。フライジェスチャーレスポンスでTableLayoutsスクロールを行うには、各TableLayoutをScrollViewでラップします。 – Sam

+0

RelativeLayoutの利点は何ですか? – callback

答えて

0

ラップScrollViewとそれぞれのtableView、及び割合でそれらの間で画面を分割して各ScrollView android:layout_weightプロパティに設定されたあなたが望みます。

関連する問題