【问题标题】:ImageView, how do you getSrc programatically for a drawable?ImageView,您如何以编程方式为可绘制对象获取 Src?
【发布时间】:2014-11-18 10:32:24
【问题描述】:

因此,对于 ImageView,有一个 imageView.getBackground() 返回背景可绘制对象。有没有办法像这样以编程方式获取 src 可绘制对象?

这是我的意思的一个小例子:

main.xml的sn-p

...
<ImageView
    android:id="@+id/main_iv"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/imageSrc"
    android:background="@drawable/imageBG" />
...

Java

public class ActivityMain extends Activity {
    ImageView iv;
    ...

    ...
    @Override
    public void onCreate(Bundle sIS){
        super.onCreate(sIS);
        setContentView(R.layout.main);
        iv = (ImageView)findViewById(R.id.main_iv);
        Drawable bg = iv.getBackground();
        // Drawable source = iv.getSource(); but this method does not exist
    }
...
}

【问题讨论】:

    标签: android imageview drawable src


    【解决方案1】:

    Call getDrawable()ImageView 中获取Drawable

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多