フルスクリーン背景として画像(menumain)を入れたいです。私のコードは:背景画像AndroidStudio
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainactivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.hgyghyfghyu.apkana40.MainActivity"
tools:showIn="@layout/activity_main"
android:background="@drawable/menumain"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:paddingRight="10dp"
android:paddingLeft="15dp"
android:id="@+id/mainavatarbck">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainavatar"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginRight="10dp"
android:id="@+id/mainnamebck">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="7dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mainname"
android:textStyle="bold"
android:textSize="25sp"
android:textColor="#FFFFFF"
android:paddingTop="10dp"
android:layout_alignParentTop="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/maincity"
android:textSize="10sp"
android:textColor="#FFFFFF"
android:layout_below="@+id/mainname"
android:layout_centerInParent="true"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:id="@+id/mainbackbtn">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="#FFFFFF"
android:id="@+id/mainbackicon"
android:layout_centerInParent="true"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:paddingTop="10dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/MainContainer">
</FrameLayout>
</LinearLayout>
</LinearLayout>
画像がフルスクリーンで表示されないため問題があります。周囲に「空白」があります(画像は中央にあります)。この問題を解決するにはどうすればよいですか?
実際に私が持っている:私のコードでは
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainactivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.hgyghyfghyu.apkana40.MainActivity"
tools:showIn="@layout/activity_main"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/menumain"
android:scaleType="fitXY"/>
//info
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:paddingRight="10dp"
android:paddingLeft="15dp"
android:id="@+id/mainavatarbck">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainavatar"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginRight="10dp"
android:id="@+id/mainnamebck">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="7dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mainname"
android:textStyle="bold"
android:textSize="25sp"
android:textColor="#FFFFFF"
android:paddingTop="10dp"
android:layout_alignParentTop="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/maincity"
android:textSize="10sp"
android:textColor="#FFFFFF"
android:layout_below="@+id/mainname"
android:layout_centerInParent="true"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:id="@+id/mainbackbtn">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="#FFFFFF"
android:id="@+id/mainbackicon"
android:layout_centerInParent="true"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
//koniec info
//kontener
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:paddingTop="10dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/MainContainer">
</FrameLayout>
</LinearLayout>
//koniec kontenera
</LinearLayout>
</LinearLayout>
がある:アンドロイド:背景= "描画可能/ menumain @" – littlewombat
してみてくださいandroid:scaleType = "fitXY" – MrRobot9
私はImageviewを実装してscaleTypeを使用することをお勧めします。別の問題です、私はこの画像ビューしか持っていません(まだフルスクリーンではありません)、私は自分の投稿を編集しました。それを確認できますか? – littlewombat