簡體   English   中英

在EditText中添加兩個drawable

[英]add two drawable into EditText

我使用以下代碼在EditText中放置了一個drawable:

    final Drawable x = getResources().getDrawable(R.drawable.del2);
    x.setBounds(0, 0, x.getIntrinsicWidth(), x.getIntrinsicHeight());
    atxt.setCompoundDrawables(null, null, x, null);

當我想換另一個,第一個drawable消失! 我想把兩個drawable,但顯然這是不可能的! 反正是嗎?

嘗試使用atxt.setCompoundDrawablesWithIntrinsicBounds (x, null, x, null); 代替

您正在尋找LayerDrawable。 有關一些示例的更多信息,請訪問: http//developer.android.com/guide/topics/resources/drawable-resource.html#LayerList

希望,這會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM