2012-06-12 30 views
2

我想將圖像放在TAB上,而且我需要變小。我試過了,但圖像不會改變大小。reduce ImageView

ImageView image1 = new ImageView(this); 
image1.setImageDrawable(getResources().getDrawable(R.drawable.book)); 
image1.setAdjustViewBounds(true); 
image1.setMaxWidth(10); 
image1.setMaxHeight(10); 

tabHost.addTab(tabHost.newTabSpec("Tab 1").setContent(R.id.tab1).setIndicator(image1)); 

設置選項卡的圖像可以參考XML標籤中main.xml

回答

0

嘗試使用以下代碼來設置佈局的高度和寬度佈局

image1.getLayoutParams().width = 10; 
image1.getLayoutParams().height = 10;