我想在片段中添加自己的图片。 是否可以在片段中添加例如圆圈? 我有这段代码:
public static class DummySectionFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
public static final String ARG_SECTION_NUMBER = "section_number";
public static final String ARG_OBJECT = "object";
public static final String ARG_DATA = "data";
public DummySectionFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle args = getArguments();
int position = args.getInt(ARG_OBJECT);
String data=args.getString(ARG_DATA);
int tabLayout = 0;
switch (position) {
case 0:
tabLayout = R.layout.fragment_company_products;
break;
case 1:
tabLayout = R.layout.fragment_main_dummy;
break;
case 2:
tabLayout = R.layout.fragment_main_dummy;
break;
case 3:
tabLayout = R.layout.fragment_main_dummy;
break;
}
View rootView = inflater.inflate(tabLayout, container, false);
TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
//dummyTextView.setText(args.getInt(ARG_OBJECT)+"\n"+data+"asd");
return rootView;
}
}
我问这个是因为我想在每个片段上更改我的图形,并且在其中一些片段上我应该添加一些2D图形,如圆形或弧形或矩形。 这可能吗? 提前谢谢
答案 0 :(得分:-1)
可以在View
的布局中添加Fragment
子类,并在onDraw
中进行自定义绘图。