簡體   English   中英

android-如何將imageview放在textview字母的頂部?

[英]android - how to put imageview on top of textview letter?

我已經從此鏈接中閱讀了答案

但我想在每個textview頂部添加一些圖標

怎么做? 任何想法?

我嘗試使用layout_abovelayout_below等,但這不是我想要的

編輯:

圖片尺寸很大,添加android:drawableTop="@drawable/image"后如何設置圖片尺寸

在此處輸入圖片說明

只需使用android:drawableTop="@drawable/YOUR_DRAWABLE"簡單即可。

要設置運行時,請使用代碼-

imgView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.imgSrc, 0, 0);

如果不想添加,請在此處(0,R.drawable.imgSrc,0,0)左上右下0。

在您的XML上使用它

android:drawableTop="@drawable/your_image"
android:drawablePadding="10dp"

或在您的活動課上

textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.your_image, 0, 0);
textView.setCompoundDrawablePadding(10);

暫無
暫無

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

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