无法使用RelativeLayout进行排列。
无法使用RelativeLayout进行排列。
我想要排列成:图片-文字-复选框\n但是我无法实现。android:layout_toRightOf,android:layout_alignParentRight=\"true\"等等都没有起作用!可能是因为充气的原因,我不知道!\n代码:\n
RelativeLayout v = (RelativeLayout) mInflater.inflate(R.layout.result_checkbox, null); final TextView titleui = (TextView) v.findViewById(R.id.titleui); titleui.setText(mytext); .... tableView.addViewItem(v2); ViewItem v2 = new ViewItem(v); tableView.addViewItem(v2);
\nXML:\n
使用RelativeLayout布局时,出现了一个问题,即无法使用布局来排列控件。该问题的原因是在RelativeLayout中的控件没有正确地设置相对位置关系。解决该问题的方法是改用LinearLayout布局,并设置其orientation为horizontal,从而使子控件水平排列在一起。
下面是改用LinearLayout布局的代码:
通过LinearLayout布局,ImageView、TextView和CheckBox控件将水平排列在一起。这样就解决了使用RelativeLayout布局时无法正确排列控件的问题。
另外,还可以将相同的布局放入ListView中进行使用。同时,可以将Drawable放入TextView中,以节省一个布局项。还可以通过设置android:contentDescription属性来消除ImageView的警告。
希望以上解决方法能对您有所帮助。