0

My code below works when placed in a class extending Activity class but addRule gives compile error saying it is undefined when I am extending ActionBarActivity.

Error:
The method addRule(int) is undefined for the type ActionBar.LayoutParams

Question: What is the alternative to addRule(int) in RelativeLayout.LayoutParams in ActionBar.LayoutParams??

private void initializeSlidingLayer() {
    LayoutParams myrlp = (LayoutParams) mySlidingLayer.getLayoutParams();

    getResources().getDrawable(R.drawable.ic_launcher);



    //for bottom
    mySlidingLayer.setStickTo(SlidingLayer.STICK_TO_BOTTOM);


    myrlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); //THIS LINE THROWS ERROR WITH ACTIONBARACTIVITY
    myrlp.width = LayoutParams.MATCH_PARENT; 
    myrlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width);

  //Adding Shadow
    mySlidingLayer.setShadowWidthRes(R.dimen.shadow_width);
    mySlidingLayer.setShadowDrawable(R.drawable.sidebar_shadow);

        //mSlidingLayer.setOffsetWidth(0);
    mySlidingLayer.setOffsetWidth(getResources().getDimensionPixelOffset(R.dimen.offset_width));    
}

Probably not relevant to the question, but I am trying to this SlidingLayer Library

user1406716
  • 9,565
  • 22
  • 96
  • 151

2 Answers2

1

Are you sure action bar uses a relative layout? If not, then you can't treat it as a relative layout layout params and can ONLY use the base layoutParams functions

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
0

I hate to answer my own questions - but I just thought of something to try (that worked) after I hit Submit.

Instead of importing:

 import android.app.ActionBar.LayoutParams;

I needed to import:

 import android.widget.RelativeLayout.LayoutParams;

I am still able to import extend ActionBarActivity.

user1406716
  • 9,565
  • 22
  • 96
  • 151