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);

文章標籤
全站熱搜
創作者介紹
創作者 西西 的頭像
西西

西西部落格@痞客邦

西西 發表在 痞客邦 留言(1) 人氣(68)