0

My goal is to implement a floating element (maybe I should say 2 elements) at the top of the screen, in a "browse" feature which displays text via a ListView. The elements I wish to float at the top while the user scrolls through various items, are a title and a back button.

As I read through this question and its answer, I found this link which describes a toolbar feature similar to the actionbar in the appCompat library.

As I started implementing the feature, Android Studio displayed an error stating that I was currently using API level 15, and would need to use API level 21 in order to use the toolbar. I intend to target a wide variety of people with this app (farmers, small business owners) so I would not like to implement a feature that excludes those with older Android phones. Does that put this feature out of the question for my business needs?

Then I started studying a solution from this question, but saw that it uses a ViewGroup and thought it looked clunky.

What would be a simple way to solve this problem?
Have I missed the mark on the answers to the S.O questions listed above? How can I put a title and "back" button that float at the top of the screen?

Community
  • 1
  • 1
Timothy Steele
  • 773
  • 1
  • 7
  • 19

2 Answers2

1

https://developer.android.com/about/dashboards/index.html

There's the breakdown by version. Currently people tend to fall into 2 groups- they target 2.3, or they target 4.0 (10 or 15). Failing to use 10 loses about 6% of the global market, but that percent is concentrated in developing markets.

I is possible to use runtime branching to use a feature where its available and omit it where it isn't, depending on how integral the feature is to your product. Also, make sure to check the support library to see if the feature has been backported.

I'm not sure why you consider using a ViewGroup to be clunky though. Do you use a LinearLayout or RelativeLayout anywhere? Then you use ViewGroup.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • You are correct. [The web page](http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html) I referenced in my question explains that the feature I'm looking for (a toolbar) has been backported through the support library, and it explains how to use it. – Timothy Steele May 06 '15 at 02:01
0

Placing the right version of the appCompat library (and placing the appCompat dependency in the right place) solved my problem with implementing it in my project.

This S.O post helped me understand that I needed to place the dependency in a different build.gradle file, under

        app > src > main

Also after reading these instructions about importing the Android Support Library, I used this line of code as a dependency:

    compile "com.android.support:appcompat-v7:22.1.0"

instead of

    compile "com.android.support:appcompat-v7:22.0.0"

and Android Studio no longer reported any errors.

Community
  • 1
  • 1
Timothy Steele
  • 773
  • 1
  • 7
  • 19