Search code examples
androidandroid-activitybackgroundimagegreendroid

Green Droid: How To Set Background Picture For GDActivity


Can anyone produce clear example of how to set up background picture in GDActivity within its constructor method (or somehow else) ?


Solution

  • Ive pointed out how to do this.

    GDActivity use special layout structure:

    <?xml version="1.0" encoding="utf-8"?>
    
    <view
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            class="greendroid.widget.ActionBarHost"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/gd_action_bar_host">
    
        <view
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                class="greendroid.widget.ActionBar"
                android:id="@+id/gd_action_bar"
                />
    
        <FrameLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/gd_action_bar_content_view"/>
    </view>
    

    So when we follow logic, we should be setting background picture for content view frame, right ?

    But that is not true.

    This is not working:

    Drawable mBackgroundDrawable = getResources().getDrawable(R.drawable.splash);
    getContentView().setBackgroundDrawable(mBackgroundDrawable);
    

    We must use standard access to a window.

    Drawable mBackgroundDrawable = getResources().getDrawable(R.drawable.splash);
    getWindow().setBackgroundDrawable(mBackgroundDrawable);
    

    Any corrections would be appreciated.