I want to try this version of TabLayout in my Xamarin app:
https://developer.android.com/reference/android/support/design/widget/TabLayout
But I can't figure out how to get a reference to it -- i.e. what package to add, and what namespace to use in Xamarin.
I did find a doc about a "tabLayout" here, but it doesn't seem like they are referring to the same one because they say it has been deprecated, which does not appear to apply to the one I want:
https://developer.android.com/reference/android/support/design/widget/TabLayout
Can anyone help?
Nuget Package
Xamarin.Android.Support.Design
Layout usage:
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
~~~
/>
Using example:
using Android.Support.Design.Widget;
Related
What is the difference between given two namespace decalration in Android.
xmlns:app="http://schemas.android.com/tools"
and
xmlns:app="http://schemas.android.com/apk/res-auto"
I am getting lint warning on using http://schemas.android.com/tools => Suspicious namespace and prefix combination
I know using http://schemas.android.com/apk/res-auto will solve the issue, but want to know the reason behind it.
Below namespace is used for android predifined components.
xmlns:app="http://schemas.android.com/tools"
But if you want to use custom components like appCompat or your custom defined views you have to use the other namespace as well
xmlns:app="http://schemas.android.com/apk/res-auto"
I'm trying to use the "tools" namespace feature in Android Studio.
I'm trying to populate the ListView with dummy list items, for design purposes. The link here says the tools:listitem="#android:layout/<filename>" should do.
But for some reason, Android Studio keeps showing Layout android:<filename> does not exist. I'm trying to find a solution for it, so I don't have to run my app again and again with dummy values for testing.
I might be overlooking something very foolish, so forgive me. Here is what I have for now:
<ListView
android:id="#+id/controllerProfiles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
tools:listitem="#android:layout/profiles_list_item"/>
And I have a file profiles_list_item.xml under res/layout. Any suggestions or alternatives?
you should change the following line :
tools:listitem="#android:layout/profiles_list_item"
to this :
tools:listitem="#layout/profiles_list_item"
with #android you say that you want to use a layout from android resources but your layout is in your own project files.
tools:listitem doesn't work with ListViews in Android Studio 2.2. This is a known bug. I've tested this in Android Studio 2.3 beta 1 and it is fixed here.
You can also move from ListView to RecyclerView as this bug doesn't occur at RecyclerViews.
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?
Testing other components in android support library,
On device classLoader can't find ViewPager however it can find other support components FragmentActivity, Fragments etc . ( using V4 as well as V13, gives same result)
What's special with ViewPager ? Does it depends on another support components to work ? (Like Fragment needs FragmentActivity)
NOTE: I think I'm properly exporting support library as dependency, else Fragment would also not have worked.
You should reference it like this:
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<v4support:ViewPager> is not correct. you need the whole package name in the xml.
android.view.ViewPager is present in Android 3.0 and later. The support library version has a different package: android.support.v4.view.ViewPager.
I want to ask you, if is possible in Android to make a control, which will take my own parameters.
I want, that my control will looks like:
<my.own.control
android:style
attributes
>
<include name=”” value=””>
<include name=”” value=””>
</my.own.control>
or
<my.own.control
Android:style
attributes
>
<include>
<name></name>
<value></value>
</include>
<include>
<name></name>
<value></value>
</include>
</my.own.control>
The reason why I want to do it this way, is to dynamically edit includes.
The most important question is, how to read includes on initialize.
Or do you have another advice?
Unfortunately this is not possible.
There is an open bug on the android project for it that was reviewed and accepted by Romain-gui, one of the lead android developers at google.
http://code.google.com/p/android/issues/detail?id=14532
There is however a workaround, it is explained very well at http://kevindion.com/2011/01/custom-xml-attributes-for-android-widgets/