html5手机页面背景图片自适应大小问题
1,输入position:fixed;top:0;left:0;将整个div固定在屏幕的顶部和左侧。
2、输入width:100%;height:100%;min-width:1000px;这个可以适合div的高度和宽度,而min-width是为了实现让屏幕宽度在1000px以内时,div的大小保持不变。
3、输入background-size: cover;-webkit-background-size: cover;-o-background-size: cover;使图片随屏幕大小同步缩放,但是有部分可能会被裁切,不过不至于会露白,下面两句是为chrome和opera浏览器作兼容。
4、输入background-position:center0;使图片的位置,居中,靠左对齐。
android按钮背景图片显示能否让他尺寸变小?
一、推荐使用.9.png格式的图片
二、缩放图片,参考
android怎么设置自适应大小的背景图片
需要给你的ImageView布局加上Android:adjustViewBounds="true"
<ImageView android:id="@+id/test_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_launcher" />
然后,在代码里设置ImageView.最大宽度和最大高度,因为adjustViewBounds属性只有在设置了最大高度和最大宽度后才会起作用
int screenWidth = getScreenWidth(this);
lp = ();
= screenWidth;
= _CONTENT;
(lp);
(screenWidth);
(screenWidth * 5); 这里其实可以根据需求而定,我这里测试为最大宽度的5倍