如何在Android中實(shí)現(xiàn)一個在圖片中添加文字功能-創(chuàng)新互聯(lián)

這篇文章給大家介紹如何在Android中實(shí)現(xiàn)一個在圖片中添加文字功能,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

成都創(chuàng)新互聯(lián)成立與2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、成都做網(wǎng)站網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元噶爾做網(wǎng)站,已為上家服務(wù),為噶爾各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792

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)目中用的是第一種,但個人感覺第二種好,因?yàn)榈谝环N多了相對或者絕對布局層。

我寫的 custom_pictext.xml

<&#63;xml version="1.0" encoding="utf-8"&#63;>
<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)一個在圖片中添加文字功能-創(chuàng)新互聯(lián)
分享URL:http://muchs.cn/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)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司