溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

自定義 Toast

發(fā)布時(shí)間:2020-10-08 01:48:03 來(lái)源:網(wǎng)絡(luò) 閱讀:324 作者:huangmeicai 欄目:移動(dòng)開發(fā)

        


View toastRoot = getLayoutInflater().inflate(R.layout.toast, null);  

       TextView message = (TextView) toastRoot.findViewById(R.id.message);  

        message.setText("My Toast");  

  

        Toast toastStart = new Toast(this);  

        toastStart.setGravity(Gravity.BOTTOM, 010);  

        toastStart.setDuration(Toast.LENGTH_LONG);  

        toastStart.setView(toastRoot);  

        toastStart.show();  

toast.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/toast_frame"
    >
 <TextView
  android:id="@+id/message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textAppearance="@style/TextAppearance.Small"
        android:textColor="@color/bright_foreground_dark"
        android:shadowColor="#BB000000"
        android:shadowRadius="2.75"
    />
</LinearLayout>


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI