-2
我試圖通過XML圖像添加背景片段:如何添加圖像(jpg)背景片段
<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:background="@drawable/background"
tools:context="com.example.ronen.sunplantnew.Fragments.Loading"></FrameLayout>
但它好好嘗試的工作,還當我試圖將其添加到活動(相對layour - 片段containee)
我也試過:
<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"
tools:context="com.example.ronen.sunplantnew.Fragments.Loading">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/background"
android:src="@drawable/background"
android:scaleType="centerCrop"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" /></FrameLayout>
但它也doen't工作 所以我怎樣才能添加背景片段?
你的第一個代碼適用於我。 –
使用'android:background =「@ drawable/ic_launcher」'而不是'android:background =「@ drawable/background」'來檢查代碼的有效性! –
它適用於android:background =「@ drawable/ic_launcher」 –