方法一:
1、在AndroidManifest.xml文件里面的Activity配置:
android:windowSoftInputMode="adjustResize|stateHidden"
2、不要将背景图片放在XML布局文件中,而是用代码实现,在onCreate方法中加上:
getWindow().setBackgroundDrawableResource(R.drawable.aa);
方法二:
1、在AndroidManifest.xml文件里面的Activity配置:
android:windowSoftInputMode="adjustResize|stateHidden"
2、布局文件设置自定义背景:
例如:
<com.***.***.MyBackgroud
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/ic_launcher"/>
3、自定义背景组件:
public class MyBackgroud extends RelativeLayout {
private Context mContext;
public MyBackgroud(Context context) {
super(context);
mContext = context;
}
public MyBackgroud(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
}
public MyBackgroud(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mContext = context;
}
public MyBackgroud(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mContext = context;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
DisplayMetrics dm = new DisplayMetrics();
WindowManager mWm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
mWm.getDefaultDisplay().getMetrics(dm);
int screenHeight = dm.heightPixels;
heightMeasureSpec = MeasureSpec.makeMeasureSpec(screenHeight, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
方法三:
1、在AndroidManifest.xml文件里面的Activity配置:
android:windowSoftInputMode="adjustNothing|stateHidden"