編輯:關於Android編程
代碼如下:
Bitmap bitmap = mWebView.getFavicon();
Drawable drawable = new BitmapDrawable(bitmap);
// edit.setCompoundDrawables(drawable, null, null, null);
drawable = this.getResources().getDrawable(R.drawable.history);
edit.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
edit.setText(cur_url);
// edit.setMaxLines(1);
setCompoundDrawablesWithIntrinsicBounds與setCompoundDrawables的區別:
setCompoundDrawables 畫的drawable的寬高是按drawable.setBound()設置的寬高,所以才有The Drawables must already have had setBounds(Rect) called.
而setCompoundDrawablesWithIntrinsicBounds是畫的drawable的寬高是按drawable固定的寬高,即通過getIntrinsicWidth()與getIntrinsicHeight()獲得,所以才有 The Drawables' bounds will be set to their intrinsic bounds.
看下面方法:
public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top,
Drawable right, Drawable bottom) {
if (left != null) {
left.setBounds(0, 0, left.getIntrinsicWidth(), left.getIntrinsicHeight());
}
if (right != null) {
right.setBounds(0, 0, right.getIntrinsicWidth(), right.getIntrinsicHeight());
}
if (top != null) {
top.setBounds(0, 0, top.getIntrinsicWidth(), top.getIntrinsicHeight());
}
if (bottom != null) {
bottom.setBounds(0, 0, bottom.getIntrinsicWidth(), bottom.getIntrinsicHeight());
}
setCompoundDrawables(left, top, right, bottom);
XML在各種開發中都廣泛應用,Android也不例外。作為承載數據的一個重要角色,如何讀寫XML成為Android開發中一項重要的技能。今天就由我向大家介紹一下在Andr
PS:用了一下個推.感覺實現第三方應用的推送功能還是比較簡單的.官方文檔寫的也非常的明確.學習內容:1.使用個推實現第三方應用的推送.所有的配置我最後會給一個源代碼,內部
概述:單線程下載很簡單,就是開啟一個線程去下載資源再進行本地保存;多線程下載是通過RandomAccessFile(隨機文件讀寫操作類)來設置每個線程讀取文件的起始點位置
Android結合版最近幾個版本在包大小配額上超標了,先後采用了包括圖片壓縮,功能H5,無用代碼移除等手段減包,還是有著很大的減包壓力。組內希望我能從代碼的角度減少一些包