title: Multiple projects depending on 1 library
body: <p>I'm not sure SO is the right place to ask this question so let me know if I should maybe post it on ProgrammersSE.</p>
  
  <p>I've got an Android library project which comes with some functionality and some basic XML files. In the nearest future I'll be developing multiple apps which will heavily depend on that library - it's possible that some of them will only differ in that they'll be using different XML layout files and image resources. As far as I know Android will automatically pick the ones from the regular projects instead of the library one if the names of the appropriate files are the same so this shouldn't be a problem.</p>
  
  <p><strong>The problem is I expect that some of the projects will have to have a slightly extended functionality - meaning I'd have to, e.g., extend the classes which are in the library project.</strong></p>
  
  <p>I just tried that out but obviously that didn't work as I wasn't overriding the entire code of a class - just adding to it, meaning I seemingly can't have the the library Activities call the classes from my regular project.</p>
  
  <p><strong>Is there any way around that without using reflection?</strong></p>
  
  <p><strong>Is there maybe a better way of handling such a situation?</strong></p>
  
  <p>Edit for clarification:</p>
  
  <p>Thanks to @jucas and @Alex Cohn for the answers and the links. I'm not sure if the solutions you wrote are applicable to my situation - I'd probably have to see examples of those coded to decide if I can do anything similar in my project.</p>
  
  <p>Here's an example of what makes this problematic for me: say in my library project I've got a class called MyActivity which extends Activity and implements OnScrollChangedListener because there's a ScrollView in it whose background has to scale. There could be something like this in it:</p>
  
  <pre><code>@Override
  public void onScrollChanged() {
  
      int currentScrollOffsetY = this.scrollView.getScrollY();
  
      // No case for further back than the bottom of the screen (lower than 0)
      // and if it's higher than where it should stop, keep it at that point
      if (currentScrollOffsetY &gt; this.screenHeightPx * MULTIPLIER_Y_ANIMATION_STOP) {
  
          currentScrollOffsetY = (int) (this.screenHeightPx * MULTIPLIER_Y_ANIMATION_STOP);
      }
  
      // Set the pivot points of the background images
      this.imageBackground.setPivotX(this.imageBackground.getWidth() / 2.0f);
      this.imageBackground.setPivotY(0);
  
      // Scale the background
      float newBackgroundScale = 1 - (float) currentScrollOffsetY / (float) this.screenHeightPx;
  
      if (newBackgroundScale &lt; 0.75f) {
  
          newBackgroundScale = 0.75f;
      }
  
      this.imageBackground.setScaleX(newBackgroundScale);
      this.imageBackground.setScaleY(newBackgroundScale);
  }
  </code></pre>
  
  <p>As you can see, the new scale for the background image is never smaller than 0.75 of the original size. Now if one of the projects using the library project needed that to be 0.8 instead, I could just move the value from the code to the XML values resources and it should be dynamically read from there - that's perfectly fine.</p>
  
  <p>But what if I not only wanted to do that but also scale another ImageView? </p>
  
  <pre><code>    this.imageBackground.setScaleX(newBackgroundScale);
      this.imageBackground.setScaleY(newBackgroundScale);
      this.differentImageBackground.setScaleX(newBackgroundScale);
      this.differentImageBackground.setScaleY(newBackgroundScale);
  </code></pre>
  
  <p><strong>How could this be achieved?</strong> I'm sorry if I don't understand this straight away - I've never done anything like this yet and some concepts are a bit difficult for me to get my head around them.</p>