我正在尝试创建一个包含文本和图像的屏幕.我希望图像像网格一样布局,如下所示,但我希望它们没有周围ScrollView提供的滚动功能.
图像最能说明我的问题:

<ScrollView>
<LinearLayout>
<ImageView />
<TextView />
<GridView />
<TextView />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
什么是显示不同数量图像的网格的最佳方法,其中网格没有滚动功能?
请注意,禁用GridView的滚动功能不起作用,因为这只会禁用滚动条但不显示所有项目.
更新:下图显示了在GridView中禁用滚动条的情况.

我在gridview中有一个背景图像,我想禁用gridview的滚动,这样它就不会滚动图像.我该怎么做呢?
我想用这样的行来创建自定义TableLayout:
电视用于TextView,即我想在行中添加11个TextView:

每行以标题开头,然后我添加5对TextView,这样表格行就像屏幕一样宽. 这是我的代码:
public class FlowTable extends TableLayout {
private Context context;
public FlowTable(Context context) {
super(context);
this.context = context;
}
public FlowTable(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
public void addContent(List<ResultItem> data) {
TableRow tableRow = new TableRow(context);
LayoutParams params = new LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);
for (int i = 0; i < data.size(); i++) {
if (i % 5 == 0) {
this.addView(tableRow, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
tableRow = new TableRow(context);
TextView tvRange = new …Run Code Online (Sandbox Code Playgroud) 现在是时候为我探索Android了.我设计了一个ui,如下所示,事情是我对第一帧中应该做什么感到困惑,以获得9x9网格.实际上,我在核心java中开发了同样的东西,通过使用for循环在每个单元格中放置81个JTextFields并且在gridbaglayout的帮助下,我的应用程序完全正常工作.但是在android中如何在xml中定义我的9x9单元格,因此它应该接受数字并输入数字也应该被检索以验证数独规则.以下是我的代码和图表.任何人都可以建议如何使帧1有9x9细胞?如果我在我的xml文件中使用TextEdit,它将是81个文本字段,如果我使用Canvas(我在想,不知道是否可能),我似乎无法让它接受数字并从中检索帆布板.如果有人能提供帮助我真的很感激.请放轻松,如果它看起来很愚蠢的问题(我希望不会,因为我尝试了2天),因为我是android的新手.提前致谢.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
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="#0f0"
/>
<FrameLayout
android:id="@+id/fLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="#00f">
<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/cancel"
android:text="cancel"
android:layout_span="3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</TableRow>
<TableRow>
<Button android:id="@+id/submit"
android:text="validate"
android:layout_span="3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</Button>
</TableRow>
</TableLayout>
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是UI
.
我已经阅读并尝试了有关从gridview中删除/隐藏滚动条的所有stackoverflow问题,但是,它不会消失!我正在运行棒棒糖的Samsung Galaxy S4上进行测试。
这是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llChooserContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:layout_marginTop="?android:attr/actionBarSize"
android:orientation="vertical">
<GridView
android:id="@+id/gvGallery"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_margin="10dp"
android:columnWidth="@dimen/chooser_grid_col_width"
android:fadingEdgeLength="10dp"
android:fastScrollEnabled="true"
android:scrollbars="none"
android:gravity="center"
android:numColumns="auto_fit"
android:requiresFadingEdge="vertical"
android:scrollingCache="true"
android:stretchMode="columnWidth"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的 onCreate
llChooserContainer.setVerticalScrollBarEnabled(false);
llChooserContainer.setHorizontalScrollBarEnabled(false);
gvGallery.setOnItemClickListener(this);
gvGallery.setVerticalScrollBarEnabled(false);
gvGallery.setHorizontalScrollBarEnabled(false);
gvGallery.setAdapter(imagesAdapter);
Run Code Online (Sandbox Code Playgroud)
还尝试过设置样式,例如
gvGallery.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
Run Code Online (Sandbox Code Playgroud)
并将size设置为null:
gvGallery.setScrollBarSize(0);
Run Code Online (Sandbox Code Playgroud)
和拇指为空
android:scrollbarThumbHorizontal="@null"
android:scrollbarThumbVertical="@null"
Run Code Online (Sandbox Code Playgroud)
XML中没有任何内容-> styles.xml我也尝试过清理项目,使缓存无效,每次都卸载应用程序。