我有看法尋呼機內的圖像視圖來顯示一些圖像從URL來作爲顯示在下面的屏幕截圖,的Android - 查看傳呼機內部圖像查看問題
然而,圖像應填寫(應占有完整的視圖尋呼機空間)。但是,在我的情況發生了什麼是圖像顯示在中心,即使當我設置佈局參數填補父母。
我的片段,其中i返回佈局圖像視圖:
ImageView image = new ImageView(getActivity());
ImageLoader imgLoader = new ImageLoader(MainActivity.context);
imgLoader.DisplayImage(imagePath, new Activity(), image);
LinearLayout layout = new LinearLayout(getActivity());
layout.setLayoutParams(new LayoutParams());
layout.setGravity(Gravity.CENTER);
layout.addView(image);
return layout;
視圖尋呼機:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="225dp"
android:background="@color/white"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
當圖像仍然從網址載入我會表現出像動畫一些進展,一旦加載我將設置圖像內的圖像
if (bitmap != null) {
imageView.setBackgroundResource(0);
imageView.setImageBitmap(bitmap);
} else {
imageView.setBackgroundResource(R.drawable.view_pager_progress);
final AnimationDrawable startAnimation = (AnimationDrawable) imageView
.getBackground();
imageView.setScaleType(ScaleType.CENTER);// i tried FIT_XY, dint work
startAnimation.start();
}
總而言之,我想要的是,圖像在視圖內的尋呼機應該在視圖尋呼機的水平和垂直方向上填充整個空間。任何想法如何做到這一點?
親愛的,你怎麼解決這個問題?我有同樣的問題,但與內容使用coordinatorlayout ... – Mateus 2016-01-19 11:20:34