Get inflater from Context
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater inflater = LayoutInflater.from(context);
Set height and width of Custom view programetically
view.setLayoutParams(new LayoutParams(width, height));
shape、gradient、stroke、corners、padding、solid
// create a layout
LinearLayout linearLayout = new LinearLayout(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);
linearLayout.setLayoutParams(params);
// create a textview
TextView textview = new TextView(context);
全站熱搜
留言列表