I created a simple app and set Background of LinearLayout to an image. when i run it, don't show background image. i see this line of log:
W/PackageManager﹕ Failure retrieving resources for vania.backgroundtest: Resource ID #0x0
why can't show background image? This is my Layout code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@drawable/backimage"
>
</LinearLayout>
This is my Java code:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
and this is manifest:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
i used a .jpg image with 1920*1080 (412 KB)
You should use the android:background
property of the LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/myimage"
android:orientation="vertical" >
<!-- More elements -->
</LinearLayout>
Where myimage
is a correct image in the res/drawable directory
. You can find more details in the documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With