在布局上,我想将背景图像(保持其纵横比)缩放到创建页面时分配的空间.任何人都知道如何做到这一点?
我正在使用layout.setBackgroundDrawable()并使用BitmapDrawable来setGravity进行剪切和填充,但是没有看到任何缩放选项.
任何人都可以告诉我如何调整imageButton的大小以使图像精确拟合.这是我尝试的代码,但图像放置在我定位的位置,
imageButton但我无法减小imageButton的大小,请帮我纠正这个问题...我试过的代码是......
<ImageButton>
android:id="@+id/Button01"
android:scaleType="fitXY" // i have tried all the values for this attr
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cropToPadding="false"
android:paddingLeft="10dp"
android:src="@drawable/eye"> // this is the image(eye)
</ImageButton>
Run Code Online (Sandbox Code Playgroud) 每当我将背景分配给使用wrap_content布局的视图时,如果背景图像大于视图,则视图会被拉伸,以便它可以保持整个背景.为什么会如此以及如何预防呢?即使图像是9-patch并且标记了可伸展区域,也会出现这种情况 - 为什么图像缩小到视图的大小?
如何为adnroid应用程序中的所有活动设置背景并保持其纵横比?
我正在使用android:windowBackground风格,但我不知道如何保持背景图像的纵横比。
是否只有ImageView手动为所有活动添加背景的方法?