[英]TableLayout - TextView and ImageView inline
我建立了一个将TextViews和ImageViews动态添加到TableLayout中的应用程序。 我面临一个小问题,我无法使ImageView与TextView字段内联显示。 在我的片段中,我从服务器获取了结果并将其显示在布局中。
我已经尝试了几种方法,例如将TextView的重力设置为这样的Center Vertical
我尝试限制文本字段的宽度,但无法正常工作。
firstRow.setGravity(Gravity.CENTER_VERTICAL);
这是我的行的填充方式:
businessNameRow.addView(businessNameField);
我正在动态添加集合,每个集合由7个TextView行和每行1个ImageView组成,如下所示:
TableRow firstRow = new TableRow(getActivity().getApplicationContext());
TableRow secondRow = new TableRow(getActivity().getApplicationContext());
TableRow thirdRow = new TableRow(getActivity().getApplicationContext());
TableRow fourthRow = new TableRow(getActivity().getApplicationContext());
TableRow fifthRow = new TableRow(getActivity().getApplicationContext());
TableRow sixthRow = new TableRow(getActivity().getApplicationContext());
TableRow imageRow = new TableRow(getActivity().getApplicationContext());
TableRow seventhRow = new TableRow(getActivity().getApplicationContext());
然后我将行添加到表中
final TableLayout tl = (TableLayout)root.findViewById(R.id.tableResultsGPS);
tl.addView(firstRow); //And so on
我的TableLayout放置在ScrollView中,因此我可以滚动浏览结果列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.