這篇文章給大家介紹如何在Android中實(shí)現(xiàn)一個(gè)在圖片中添加文字功能,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
Android自定義實(shí)現(xiàn)圖片加文字功能
分四步來寫:
1,組合控件的xml;
2,自定義組合控件的屬性;
3,自定義繼承組合布局的class類,實(shí)現(xiàn)帶兩參數(shù)的構(gòu)造器;
4,在xml中展示組合控件。
具體實(shí)現(xiàn)過程:
一、組合控件的xml
我接觸的有兩種方式,一種是普通的Activity的xml;一種是父節(jié)點(diǎn)為merge的xml。我項(xiàng)目中用的是第一種,但個(gè)人感覺第二種好,因?yàn)榈谝环N多了相對(duì)或者絕對(duì)布局層。
我寫的 custom_pictext.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:id="@+id/custom_pic_iv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@mipmap/a" /> <TextView android:id="@+id/custom_date_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@id/custom_pic_iv" android:layout_marginBottom="5dp" android:layout_marginLeft="8dp" android:text="2017" /> <TextView android:id="@+id/custom_text_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/custom_pic_iv" android:layout_marginLeft="4dp" android:layout_marginTop="4dp" android:text="題目" /> </RelativeLayout>
網(wǎng)頁題目:如何在Android中實(shí)現(xiàn)一個(gè)在圖片中添加文字功能-創(chuàng)新互聯(lián)
分享URL:http://m.kartarina.com/article48/cddghp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、外貿(mào)建站、企業(yè)建站、建站公司、手機(jī)網(wǎng)站建設(shè)、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容