0
好吧我已經花了幾個小時嘗試弄清楚這個問題,大多數解決方案都不起作用,那些做了工作的解決方案使得圖像的高度和寬度比例保持不變,我想要的是能夠從URL設置imageview圖像,並使寬度match_parent和高度175dp。請有人幫助我!從url設置imageview圖像
好吧我已經花了幾個小時嘗試弄清楚這個問題,大多數解決方案都不起作用,那些做了工作的解決方案使得圖像的高度和寬度比例保持不變,我想要的是能夠從URL設置imageview圖像,並使寬度match_parent和高度175dp。請有人幫助我!從url設置imageview圖像
使用下面的代碼
<ImageView android:layout_width="match_parent"
android:layout_height="175dp"
android:scaleType="fitXY"
/>
public static void LoadImageFromWebOperations(String url,ImageView img) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
img.setImageDrawable(d);
} catch (Exception e) {
}
}
http://stackoverflow.com/questions/17120230/android-set-imageview-to-url/17120523#17120523。檢查這可能有所幫助 – Raghunandan