我正在尝试制作一个 3 列,TableLayout但我什么也没看到。这是我的Java代码:
TableLayout tl = (TableLayout)findViewById(R.id.tableLayout1);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView tv = new TextView(this);
tv.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tv.setText(data[0]);
tr.addView(tv);
TextView tv1 = new TextView(this);
tv1.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tv1.setText(data[1]);
tr.addView(tv1);
TextView tv2 = new TextView(this);
tv2.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tv2.setText(data[2]);
tr.addView(tv2);
/* Add row to TableLayout. */
tl.addView(tr,new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Run Code Online (Sandbox Code Playgroud)
这是我的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/LinearLayout1" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="350dp"
android:layout_marginTop="10dp"
>
</TableLayout>
<Button
android:id="@+id/BorrarPedido" …Run Code Online (Sandbox Code Playgroud) 好吧,我的应用程序有一个包含很多表格的tablelayout,但我怎么能在它们之间划分呢?例如:一个桌子,在那之后是一条线,在另一个桌子之后,依此类推.那有一些属性吗?
我有一个包含在 Scrollview 中的 TableLayout。TableLayout 在运行时以编程方式填充。该表包含航班到达信息。已填充 TableLayout 之一,我希望能够向下滚动到当前时间段。
如果我知道要滚动到表中第 40 行(共 100 行),我该怎么做?
这是布局的 XML。提前致谢。
<LinearLayout
android1:id="@+id/LinearLayout20"
android1:layout_width="fill_parent"
android1:layout_weight="1"
android:orientation="vertical"
android1:background="#000000" android:layout_height="10000dp" android:measureWithLargestChild="true">
<ScrollView
android1:id="@+id/scrollView1"
android1:layout_width="match_parent"
android1:layout_height="wrap_content">
<TableLayout
android1:id="@+id/arrivalstable"
android1:layout_width="wrap_content"
android1:layout_height="wrap_content">
</TableLayout>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我正在玩 LibGDX 并尝试设置一个简单的棋盘游戏。
public void show() {
width = Gdx.graphics.getWidth();
height = Gdx.graphics.getHeight();
viewport = new FitViewport(STAGE_WIDTH, STAGE_HEIGHT);
stage = new Stage(viewport);
sceneBoard = new GridSceneBoard(10, 30, GridBoardCell.Type.CHECKERED);
rootTable = new Table();
rootTable.setFillParent(true);
sceneBoard.setFillParent(true);
rootTable.add(sceneBoard);
stage.addActor(rootTable);
Gdx.input.setInputProcessor(stage);
}
Run Code Online (Sandbox Code Playgroud)
aGridSceneBoard扩展了 Table,可以方便地制作像棋盘一样的图像网格。渲染方法如下:
public void render(float delta) {
// Set black background.
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// Uncomment for table lines during debugging.
rootTable.debug();
sceneBoard.debug();
Table.drawDebug(stage);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
Run Code Online (Sandbox Code Playgroud)
我想嵌套表格以获得更好的 UI 布局(最终),但是当我运行代码时,我得到:

我已经阅读了 TableLayout 的文档以及 LibGDX 的 scene2d.ui 文档,我做错了什么?我正在使用 LibGDX …
我正在使用 tablelayout 进行活动。在开始时,布局很好,但是当一些数据填充 Activity 上的文件时,布局会改变它的形式,走出屏幕。如何阻止布局?
我要求作为最后的努力来遵守我的良心并用CSS做到这一点.我想使用CSS来布局这个简单的表单,但我花了两个小时试图获得它并且总是最终出现对齐问题.我用十分钟就用它做了.
我需要右对齐标签,名称行分为两部分,标签与输入文本正确垂直对齐,以及输入的所有右边缘排成一行.在CSS中做什么需要做什么?

编辑:添加我的CSS,看看我哪里出错了.
这就是我用CSS获得的:
.form_row {
width: 500px;
}
.form_row label {
text-align: right;
width: 150px;
float: left;
margin-top: 6px;
padding-right: 6px;
}
#id_first_name, #id_last_name {
width: 130px;
}
#id_email, #id_password {
width: 300px;
}
Run Code Online (Sandbox Code Playgroud)
标记:
<div class="form_row">
<label for="id_first_name">Name:</label>
<input id="id_first_name" type="text" name="first_name" />
<input id="id_first_name" type="text" name="last_name" />
</div>
<div class="form_row">
<label for="id_email">Email:</label>
<input type="text" name="email" id="id_email"/>
</div>
<div class="form_row">
<label for="id_password">Password:</label>
<input id="id_password" type="password" name="password" />
</div>
Run Code Online (Sandbox Code Playgroud)
结果如下:

我正在TableLayout动态添加行,每行都有多个行TextView.
我想循环我的每一行,我TableLayout想更新一些行(不是每一行),例如TextView我的行中的文本.我该怎么办呢?
我已下载示例tablelayout源代码,它工作正常.我试图在表格布局的底部显示四个图像按钮但仍然没有工作.
当前图片:

我试图在表格布局的底部显示这4个按钮:

这是我的代码:我希望在我的表格布局底部合并我的源代码请帮助我.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/ttt3"
android:layout_width="150dip"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/bt_blue" />
<Button
android:id="@+id/ttt2"
android:layout_width="150dip"
android:background="@drawable/bt_yellow"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/ttt3"
/>
<Button
android:id="@+id/ttt1"
android:layout_width="150dip"
android:background="@drawable/bt_green"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/ttt2"
/>
<Button
android:id="@+id/ttt0"
android:layout_width="150dip"
android:layout_height="40dip"
android:background="@drawable/bt_red"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="bottom"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
表格代码:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableRow4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="@+id/textView9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="18dp"
android:text="Weather Table"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我希望一旦我点击按钮,就会出现包含该表格的片段.除表格布局外,一切都会显示.我没弄明白为什么.
这是我的表格布局:
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<TableLayout android:id="@+id/simpleTableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" >
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="18dp" android:text="Row 1" android:layout_span="3"
android:padding="18dip" android:background="#b0b0b0"
android:textColor="#000"/>
<TextView
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="18dp" android:text="Row 1" android:layout_span="3"
android:padding="18dip" android:background="#b0b0b0"
android:textColor="#000"/>
</TableRow>
</TableLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
这是我片段的重要方法:
class TablePresentation : DialogFragment(),tableContract.View
{
...
override fun onCreateView(inflater: LayoutInflater?, parent: ViewGroup?, state: Bundle?): View? {
super.onCreateView(inflater, parent, state)
val view = activity.layoutInflater.inflate(R.layout.table_fragment, parent, false)
view.findViewById<View>(R.id.button_close)?.setOnClickListener({ dismiss() })
return view
}
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { …Run Code Online (Sandbox Code Playgroud)