本文介绍了滚动型不显示整个TableLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想中的滚动型
显示 TableLayout
。表中有9 的TableRow
秒,但滚动型
开始显示第4行的部分,我不能sroll达看到上面的行。
I want to display a TableLayout
within a ScrollView
. The Table has 9 TableRow
s but the ScrollView
starts displaying parts of the 4th row and I can't sroll up to see the rows above.
在XML的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/uyi_choosepi_relativelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:keepScreenOn="true" >
<MyGallery
android:id="@+id/uyi_gallery_originals"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<TableLayout
android:id="@+id/uyi_choosepi_buttontable"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:stretchColumns="0,1" >
<TableRow >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hilfe"
android:onClick="showHelp"
android:drawableLeft="@android:drawable/ic_menu_help" />
<Button
android:id="@+id/uyi_choosepi_savepw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fertig"
android:clickable="false"
android:enabled="false"
android:onClick="savePassword"
android:drawableLeft="@android:drawable/ic_menu_save"/>
</TableRow>
</TableLayout>
<ScrollView
android:id="@+id/uyi_choosepi_scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/uyi_gallery_originals"
android:layout_above="@id/uyi_choosepi_buttontable">
<TableLayout
android:id="@+id/uyi_choosepi_tablelayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center_vertical"
android:shrinkColumns="0,1,2" />
</ScrollView>
</RelativeLayout>
的的TableRow
■在 uyi_choosepi_tablelayout
,其中加入编程方式如下:
The TableRow
s in the uyi_choosepi_tablelayout
where added programmatically as follows:
table = (TableLayout) findViewById(R.id.uyi_choosepi_tablelayout);
for (int i = 0; i < UYIMainActivity.PASS_LENGTH; i++) {
TableRow row = new TableRow(table.getContext());
originalViews[i] = new ImageView(row.getContext());
originalViews[i].setAdjustViewBounds(true);
originalViews[i].setScaleType(ScaleType.FIT_XY);
originalViews[i].setPadding(3, 3, 3, 3);
originalViews[i].setImageResource(R.drawable.oempty);
distortedViews[i] = new ImageView(row.getContext());
distortedViews[i].setAdjustViewBounds(true);
distortedViews[i].setScaleType(ScaleType.FIT_XY);
distortedViews[i].setPadding(3, 3, 3, 3);
distortedViews[i].setImageResource(R.drawable.wempty);
ImageView arrow = new ImageView(row.getContext());
arrow.setAdjustViewBounds(true);
arrow.setScaleType(ScaleType.FIT_XY);
arrow.setMaxWidth(80);
arrow.setPadding(3, 3, 3, 3);
arrow.setImageResource(R.drawable.arrow_active);
row.addView(originalViews[i]);
row.addView(arrow);
row.addView(distortedViews[i]);
table.addView(row);
}
我希望你能给我一个提示!
I hope you can give me a hint!
推荐答案
我解决我的问题,通过周围的 TableLayout
与的LinearLayout
I solved my problem by surrounding the TableLayout
with a LinearLayout
<ScrollView
android:id="@+id/uyi_choosepi_scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/uyi_gallery_originals"
android:layout_above="@id/uyi_choosepi_buttontable">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="@+id/uyi_choosepi_tablelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:shrinkColumns="0,1,2" />
</LinearLayout>
</ScrollView>
这篇关于滚动型不显示整个TableLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!