So basically, I have an App which works on all my devices and emulators provided from google. But there are a few of people reporting no background image which makes text unreadable. Please help, I have no idea where the app goes wrong.
here's my FragmentActivity file (basic part)
public class MainActivity extends FragmentActivity{
private FragmentTabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bundle b1 = new Bundle();
b1.putInt("tabId",111);
Bundle b2 = new Bundle();
b2.putInt("tabId",222);
final FragmentManager fm = getSupportFragmentManager();
mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
mTabHost.setup(this, fm, R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("main").setIndicator("MAIN"), TabContentFragment.class, b1);
mTabHost.addTab(mTabHost.newTabSpec("massReading").setIndicator("MASS READING"), TabContentFragment.class, b2);
TabWidget tw = mTabHost.getTabWidget(); //this tabwidget is generated after "addTab", the one from layout is not doing anything
tw.setVisibility(0x00000008); // = "GONE"
}
}
and "activity_main" Layout file
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"> *******//This is the background image I need to display********
<LinearLayout
android:id="@+id/top"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/padding"
android:gravity="center"
android:background="@android:color/transparent"
>
<Button
android:id="@+id/back"
style="@style/btn"
android:background="@drawable/back"
/>
<TextView
android:id="@+id/title"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:textStyle="bold"
style="@style/title"
android:gravity="center"
/>
<Button
android:id="@+id/down"
style="@style/btn"
android:background="@drawable/decrease"
android:layout_marginRight="15dp"
/>
<Button
android:id="@+id/up"
style="@style/btn"
android:background="@drawable/increase"
/>
</LinearLayout>
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="@android:color/transparent"
>
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
/>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.v4.app.FragmentTabHost>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/rg"
>
<RadioButton
android:id="@+id/main"
style="@style/rb"
android:drawableTop="@drawable/reflection"
android:text="@string/rb_left"
/>
<RadioButton
android:id="@+id/mr"
style="@style/rb"
android:drawableTop="@drawable/readings"
android:text="@string/rb_right"
/>
</RadioGroup>
</LinearLayout>
and the Fragment file which just 2 webviews
public class TabContentFragment extends Fragment {
WebView wv;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (container == null) {
return null;
}
Bundle b = getArguments();
int tabId = b.getInt("tabId");
wv = (WebView)inflater.inflate(R.layout.tab_content, container, false);
wv.setId(tabId);
wv.setVerticalScrollBarEnabled(false);
wv.setBackgroundColor(0);
if(tabId==111)
{
String htmlString = "<html xmlns='http://www.w3.org/1999/xhtml'>stuff</html>";
wv.loadDataWithBaseURL("",htmlString, "text/html", "UTF-8", "");
}
else
{
String htmlString = "<html xmlns='http://www.w3.org/1999/xhtml'>stuff</html>";
wv.loadDataWithBaseURL("",htmlString, "text/html", "UTF-8", "");
}
return wv;
}
}
Check the details on the devices that are complaining about no bitmap showing, look for the VM budget. If the device does not have enough memory to hold the bitmap, the bitmap may simply be set to null (or no background). Given your symptoms I would say this is the problem.