在xml中我們一般進(jìn)行一個(gè)textView的書寫的時(shí)候
<TextView
android:id="@+id/tx1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Hello World!"
android:textSize="17sp" />
如果你想要?jiǎng)討B(tài)代碼設(shè)置的時(shí)候也能夠存在這樣的padding效果和textSize大小
(1)邊距
**需要進(jìn)行dp轉(zhuǎn)換成px**
textView2.setPadding(AttrGet.dp2px(10),0,0,0);
(2)文字大小不僅需要sp轉(zhuǎn)換成px還需要getPaint()方法
textView2.getPaint().setTextSize(AttrGet.sp2px(17));