【教えてください】TableLayoutにおけるScrollviewについて

3,274 views
Skip to first unread message

Yasu

unread,
Jan 4, 2013, 9:44:11 AM1/4/13
to android-g...@googlegroups.com
皆さん、こんばんは。Yasuです。
 
色々と調べましたが、自分の技量不足の為、ご存知のかたご教授願えないでしょうか。
 
xmlのレイアウトで画面を作成しておりまして
 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />
    <TableRow >
        <Button
            android:layout_width="0dp"
            android:layout_marginLeft="1dp"
            android:layout_marginRight="1dp"
            android:layout_weight="1"
            android:text="a" />
        <Button
            android:layout_width="0dp"
            android:layout_marginLeft="1dp"
            android:layout_marginRight="1dp"
            android:layout_weight="1"
            android:text="b" />
        <Button
            android:layout_width="0dp"
            android:layout_marginLeft="1dp"
            android:layout_marginRight="1dp"
            android:layout_weight="1"
            android:text="c" />
        <Button
            android:layout_width="0dp"
            android:layout_marginLeft="1dp"
            android:layout_marginRight="1dp"
            android:layout_weight="1"
            android:text="d" />
        <Button
            android:layout_width="0dp"
            android:layout_marginLeft="1dp"
            android:layout_marginRight="1dp"
            android:layout_weight="1"
            android:text="e" />
    </TableRow>
            ・
            ・
            ・
            ・
            ・
</TableLayout>
と画面を作成しています。
 
TableRowは無限に増えてもTextViewは固定し、TableRowをスクロールさせたいと考えています。イメージとしてはTextViewの下にTableRowが潜り込みます。
Scrollviewを実装すればいいのは分かっておりますが、なぜか反応してくれません。
 
レイアウトの基本で申し訳ありませんが、どの箇所にScrollviewを記載すればいいのか教えて頂いてよろしいでしょうか。
 
よろしくお願いいたします。
 

Hirokazu Fukami

unread,
Jan 4, 2013, 9:55:12 AM1/4/13
to android-g...@googlegroups.com
こんばんはfkmです。
今年も1年よろしくお願いします。

実際に試してはないですが、こんな感じでどうでしょうか?
- TextViewは上に固定し、
- スクロールさせたい部分にScrollViewを置き、
- 子にTableViewをいれる
<LinearLayout
orientaion="vertical">
<TextVliew />
<ScrollView
layout_height="wrap_content">
<TableView>
</TableView>
</ScrollView>
</LinearLayout>

2013/1/4 Yasu <yasu...@gmail.com>:
> --
> このメールは Google グループのグループ「日本Androidの会」の登録者に送られています。
> このディスカッションをウェブ上で閲覧するには、https://groups.google.com/d/msg/android-group-japan/-/nT4L7JD2kWoJ
> にアクセスしてください。
> このグループに投稿するには、android-g...@googlegroups.com にメールを送信してください。
> このグループから退会するには、android-group-j...@googlegroups.com
> にメールを送信してください。
> 詳細については、http://groups.google.com/group/android-group-japan?hl=ja
> からこのグループにアクセスしてください。



--
-------------------------------------------------------------
深見 浩和(Hirokazu Fukami)

URI:http://www.fkmsoft.jp
email: f...@fkmsoft.jp

杉田敏典

unread,
Jan 4, 2013, 10:09:03 AM1/4/13
to android-g...@googlegroups.com

杉田です。
同じようなボタンが並ぶだけなのなら、TableViewではなくて、ListViewにしたほうが、何かといいのではないかと思います。
内容にもよりますが、ScrollView+TableViewで内容が大きくなるとメモリの圧迫を心配する必要が出てきてしまいます。

Yasu

unread,
Jan 4, 2013, 10:22:58 AM1/4/13
to android-g...@googlegroups.com
fkmさん、早速の返信ありがとうございます。
 
ご指摘のように変更し、グラフィカルレイアウトで確認しても意図していたようになりませんでした。。。

2013年1月4日金曜日 23時55分12秒 UTC+9 fkm:
> このグループに投稿するには、android-group-ja...@googlegroups.com にメールを送信してください。
> このグループから退会するには、android-group-japan+unsubscribe@googlegroups.com

Yasu

unread,
Jan 4, 2013, 10:49:15 AM1/4/13
to android-g...@googlegroups.com
杉田様、返信有難う御座います。
 
メモリの圧迫ですか。。。Out of Memoryは出てほしくないですし。。。
 
しかしLinearLayout で作成してみましたが、結果は一緒でした。。。
ScrollViewも問題ないはずなんですが。。。
 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" >
        <requestFocus android:layout_width="wrap_content" />
    </EditText>
    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp" >
                      <Button
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"

                          android:layout_marginLeft="1dp"
                          android:layout_marginRight="1dp"
                          android:layout_weight="1"
                          android:text="ki" />
                      <Button
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"

                          android:layout_marginLeft="1dp"
                          android:layout_marginRight="1dp"
                          android:layout_weight="1"
                          android:text="ki" />  
                      <Button
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"

                          android:layout_marginLeft="1dp"
                          android:layout_marginRight="1dp"
                          android:layout_weight="1"
                          android:text="ki" />  
                      
                      <Button
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"

                          android:layout_marginLeft="1dp"
                          android:layout_marginRight="1dp"
                          android:layout_weight="1"
                          android:text="ki" />  
                      
                      <Button
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"

                          android:layout_marginLeft="1dp"
                          android:layout_marginRight="1dp"
                          android:layout_weight="1"
                          android:text="ki" />  
                      
                      <Button
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"

                          android:layout_marginLeft="1dp"
                          android:layout_marginRight="1dp"
                          android:layout_weight="1"
                          android:text="ki" />  
  
                      <Button
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"

                          android:layout_marginLeft="1dp"
                          android:layout_marginRight="1dp"
                          android:layout_weight="1"
                          android:text="ki" />  
        </LinearLayout>
    </ScrollView>
</LinearLayout>
 

2013年1月5日土曜日 0時09分03秒 UTC+9 杉田 敏典:

杉田敏典

unread,
Jan 4, 2013, 9:25:48 PM1/4/13
to android-g...@googlegroups.com

adapterを作成してListViewを使えば、スクロールもメモリの管理も(ある程度までは)勝手にやってくれます。

LinearLayout
- TextView
- ListView
  - LinearLayout
    - Button
    - Button
    …

というような構成にしてみてはいかがですか?

2013/01/05 0:49 "Yasu" <yasu...@gmail.com>:
--
このメールは Google グループのグループ「日本Androidの会」の登録者に送られています。
このディスカッションをウェブ上で閲覧するには、https://groups.google.com/d/msg/android-group-japan/-/pZa4SklciDMJ にアクセスしてください。
このグループに投稿するには、android-g...@googlegroups.com にメールを送信してください。
このグループから退会するには、android-group-j...@googlegroups.com にメールを送信してください。
詳細については、http://groups.google.com/group/android-group-japan?hl=ja からこのグループにアクセスしてください。

杉田敏典

unread,
Jan 4, 2013, 9:28:26 PM1/4/13
to android-g...@googlegroups.com

そういうと、一つ、勘違いしていませんか?
グラフィカルレイアウトエディタではscrollしませんよ。実機やエミュレータで実際にブログラムを動かす必要があります。

2013/01/05 0:49 "Yasu" <yasu...@gmail.com>:
杉田様、返信有難う御座います。
--

Yasu

unread,
Jan 4, 2013, 9:40:54 PM1/4/13
to android-g...@googlegroups.com
杉田様、返信有難う御座います。
 
そうですよね、失念しておりました。
エミュレータで確認したところ、無事意識した動作になりました。
 
ありがとうございました。

2013年1月5日土曜日 11時28分26秒 UTC+9 杉田 敏典:
このグループに投稿するには、android-group-ja...@googlegroups.com にメールを送信してください。
このグループから退会するには、android-group-japan+unsubscribe@googlegroups.com にメールを送信してください。
詳細については、http://groups.google.com/group/android-group-japan?hl=ja からこのグループにアクセスしてください。
Reply all
Reply to author
Forward
0 new messages