While I try to add wenchaojiang AndroidSwipeableCardStack library to my project. While I succeed to add this library but got an error in the following case.
In main Activity layout, I required adding the,
<com.wenchao.cardstack.CardStack
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:padding="10dp"
/>
Also I need to add the following with this
app:card_enable_loop="false"
app:card_enable_rotation="true"
app:card_gravity="top"
app:card_margin="20dp"
app:card_stack_size="4"
I got error as Decleration not found or error: attribute 'business.contacts.cardwithlib:card_enable_loop' not found.
I try many solutions like,
Include card 'com.android.support:cardview-v7:27.1.1' , add auto-generating xmlns:app="http://schemas.android.com/apk/res-auto" and Open their project and work fine for me in that project
I noticed that you are no including the Android's CardView but what it looks like a 3rd party library.
com.wenchao.cardstack.CardStack
Is this intentional? If so, maybe this component doesn't extend the CardView element, those specific style attributes might not be available.
Related
I upgraded to Android Support Library 23.2.0 and added
vectorDrawables.useSupportLibrary = true
to my build.gradle, so that I have vector drawable support for apis lower than 21. (See here for details).
I also replaced
android:src="#drawable/ic_create_black_24dp"
with
app:srcCompat="#drawable/ic_create_black_24dp"
in every Imageview that uses vector drawables.
The app compiles and works perfectly fine, but code analysis reports:
Error:(56, 9) Unexpected namespace prefix "app" found for tag ImageView
Why is this the case? Why is it compiling although I am getting errors?
EDIT: I have added
xmlns:app="http://schemas.android.com/apk/res-auto"
in my root layout.
Lint, Android's code analysis tool, doesn't seem to know about support vector drawables, yet. You can safely ignore the error by adding tools:ignore="MissingPrefix" to the ImageView tag.
Change ImageView to android.support.v7.widget.AppCompatImageView in your XML
You're seeing this error, because original ImageView doesn't have srcCompat attribute. This attribute is used only by AppCompatImageView, which is injected instead of ImageView you declared. This error is easy to spot when using overloaded view inflaters. Lint performs static analysis and doesn't know about hacks you can do with xml from code.
Need to add this to top parent layout :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
Add xmlns:app="schemas.android.com/apk/res-auto" as attribute either to your ImageView or to the Top-Level Tag like LinearLayout, CoordinatorLayout, RelativeLayout.. etc
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/ic_create_black_24dp"
xmlns:app="http://schemas.android.com/apk/res-auto"/>
or in parent layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto"/>
I am using this famous ViewPagerIndicator library in my project. I wanted to add color on ViewPageIndicator. I found a solution from here on StackOverflow.
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/indicator"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
app:fillColor="#FF888888"
app:pageColor="#88FF0000"
app:strokeColor="#FF000000" />
But one thing I can't understand here: why it is written app: instead of android:? What does app: mean? I have never used app:? What is its namespace? I googled but no solution found.
For the namespace, add this: xmlns:app="http://schemas.android.com/apk/res-auto"
The app namespace is used for all 'new' attributes. For example: if I make a custom view, that has its own attributes (let's say RainbowView with new attribute 'numberOfColors'), then I have to use that attribute in the app namespace because it isn't declared in the android namespace. So use the app namespace for all custom attributes. Either attrs you defined yourself, or attrs the author of a library added (in your case for CirclePageIndicator). But most of the time, when you start typing 'strokeCo...' and you see 'strokeColor' in the autocomplete list, the namespace will be added automatically when you select it.
Probably you only need to add the missing namespace:
xmlns:app="http://schemas.android.com/apk/res-auto"
Or take a look at this answer for referencing a library:
How can I set up custom namespaces in layout file in Android studio?
I tried customizing a view from a library I'm using for my android app. The default xml code for this looks like this:
<it.gmariotti.cardslib.library.view.CardView
android:id="#+id/carddemo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"/>
This works without any problems. But when I add a new line in the element, to use my custom layout, I get an error in the opening line, that you can see in the title of this question: This is the line I was adding in the end:
card:card_layout_resourceID="#layout/custom_layout" />
This is also exactly the code that was used as an example in the docs of the library.
You probably forgot to "define" a namespace for the custom attribute card. So add this to your root-view in your xml-file:
xmlns:card="http://schemas.android.com/apk/res-auto"
I know as soon as I post this question on stackOverflow it is going to be marked as duplicate but trust me I have tried every possible solution discussed under the same topic in StackOverflow.
I am trying to add Facebook SDK in my project . After adding it under my project->properties->Android (then add facebook adk as library) , when i try to create my xml file and use it shows me red cross next to it and no matter what i do I am not able to make this error go away. Please help me..Anything help is appreciated!!
The 'Unbound Prefix' error is due to having a custom namespace in your xml that is not accounted for.
You need to add another prefix to the top of your file. It should be similar to what I've wrote below, but with PREFIX replaced by the prefix you are using.
xmlns:*PREFIX*="http://schemas.android.com/apk/res-auto"
So, in the end, your file should look something like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.facebook.widget.LoginButton
android:id="#+id/connectWithFbButton"
style="#style/com_facebook_loginview_default_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:text="#string/connect_with_facebook"
fb:login_text="#string/connect_with_facebook"
fb:logout_text="Connecting with facebook" />
</LinearLayout>
In this example I've added the prefix 'fb' and I have referenced it when using the fields login_text and logout_text :)
use
FacebookSdk.sdkInitialize(getApplicationContext());
before
super.onCreate(savedInstanceState);
Keep both library and project in the same workspace.
try to deleting this two lines
fb:login_text="#string/connect_with_facebook"
fb:logout_text="Connecting with facebook"
I have a custom view I created that resides in a library I'm referencing in my app. In the library I declared a styleable, which the view uses. In my app, I'm using the custom view from the library as such:
<nefarious.library.myappname.views.DragDropList
xmlns:ddl="http://schemas.android.com/apk/res/nefarious.library.myappname"
android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:choiceMode="singleChoice"
android:clickable="true"
android:longClickable="true"
android:focusable="true"
android:hapticFeedbackEnabled="true"
android:cacheColorHint="#00000000"
ddl:normalHeight="#dimen/list_item_height"
ddl:doubleHeight="#dimen/list_item_height_doubled"
ddl:grabber="#id/grabber"
ddl:grabberPadding="30dip"
ddl:dragndropBackground="#color/moola_light" />
Eclipse seems to be having a problem finding the stylable. Eclipse is telling me it couldn't find the resource identifier for every one of my stylable attributes.
How can I get my app to see the stylable from the library?
My question is exactly this one:
Specifying Android project dependencies (in Eclipse)
Which appears to not have been answered.
Since yout library is not packaged as an apk, you have to change custom sheme from http://schemas.android.com/apk/res/nefarious.library.myappname to http://schemas.android.com/res/nefarious.library.myappname.
I hope it will help