Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

java - Android device is not showing the background image

I have created a project, targeting android 4.4 - API Level 19, as suggested by eclipse.

Anyways, on the emulator everything looks perfect - here is a screenshot:

app screenshot

The problems comes when I install it on my real device - running android 4.1.2. Everything is just perfect and working like a charm, excepting the background image. It is showing a white background, like the picture does not exists.

Here is my xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    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" 
    android:orientation="vertical"
    android:gravity="center"
    android:padding="30dp"
    android:background="@drawable/wg_blurred_backgrounds_12"
>

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnTopJokes" 
    android:onClick="showTopJokes"   
    android:gravity="center" 
/>

<Button
    android:layout_marginTop="10dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnNewJokes" 
    android:onClick="showNewJokes" 
    android:gravity="center"
/>

<Button
    android:layout_marginTop="10dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnAllJokes" 
    android:onClick="showAllJokes" 
    android:gravity="center"
/>

<Button
    android:layout_marginTop="10dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnMyFavorites" 
    android:onClick="showFavorites" 
    android:gravity="center"
/>

<Button
    android:layout_marginTop="10dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnCategories" 
    android:onClick="showCategories"
    android:gravity="center"
/>

<Button
    android:layout_marginTop="10dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btnAddNewJoke" 
    android:gravity="center"
/>

</LinearLayout>

Isn't android:background="@drawable/wg_blurred_backgrounds_12 working on android 4.1.2 ?

Do I have to change anything in the premissions? Here is what I have now:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

I know that I miss something really small, but I'm not able to spot it as a beginner.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try with a lower-resolution background. The one you are trying might be too big. You can check that in your logcat.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...