我正在尝试使用可绘制的png来获取我的imageview以填充显示(我不关心比率).但是,fill_parent不起作用,据我所知,没有背景设置为RelativeLayout?
问候
RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:onClick="toggleAdvice"
ImageView
android:id="@+id/advice_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/pratbubbla_gron"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
Run Code Online (Sandbox Code Playgroud)
我以编程方式拉伸/剪切ImageView,可能这段代码可以帮助你:
ImageView imageView=new ImageView(context);
imageView.setAdjustViewBounds(true);
imageView.setImageBitmap(bitmap);
imageView.setMaxHeight(maxHeight);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
layout.addView(imageView);
Run Code Online (Sandbox Code Playgroud)