我为我的maiActivity编写了这个XML代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/backImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="@drawable/back" />
</RelativeLayout>
我希望当表单开始我的活动创建全屏和图像背景填充或适合活动。
答案 0 :(得分:0)
如果您想将图片作为背景,则不需要使用Imageview。
使用android:background =&#34; @ drawable / back&#34;在相对布局声明中;)
答案 1 :(得分:0)
一个选项是将布局更改为FrameLayout并将这些属性添加到ImageView:
android:src="@drawable/your_image"
android:scaleType = "centerCrop"
答案 2 :(得分:0)
试试这个:
布局
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:fitsSystemWindows="true"
android:background="#ffffff"
tools:context="com.smbds.app.activities.SplashScreenActivity">
<ImageView
android:src="@drawable/ic_branding_splashscreen"
android:layout_centerInParent="true"
android:keepScreenOn="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
活动
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash_screen);
resources = getResources();
答案 3 :(得分:0)
你可以这样做:
1-实际上
public class YoutActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
}
2- XML:
您可以在AndroidManifest.xml
<activity android:name=".YoutActivity "
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
当你设置绑定
时,也会让图像充满屏幕