Comments (18)
so simple:
just create a class like this.and extend from SmartTablayout and override createDefaultTabView and setTypeface up in it.
/////////////////////////////////////////////////////
public class MyTabLayout extends SmartTabLayout {
public MyTabLayout(Context context) {
super(context);
}
public MyTabLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyTabLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected TextView createDefaultTabView(CharSequence title) {
TextView myTextView = super.createDefaultTabView(title);
myTextView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "font/" + "iran_sans_number" + ".ttf"));
return myTextView;
}
}
from smarttablayout.
Hi, @saeedsh92
The default tab attribute does not support the typeface.
Try using the layout of the custom tab.
e.g.
custom_tab_with_typeface.xm:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="14sp"
android:textColor="@color/custom_tab"
android:gravity="center"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:typeface="sans"
>
</TextView>
tab_layout.xml:
<com.ogaclejapan.smarttablayout.SmartTabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@id/viewpagertab"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_height"
...
app:stl_customTabTextLayoutId="@layout/custom_tab_with_typeface"
app:stl_customTabTextViewId="@id/custom_text"
/>
from smarttablayout.
thank you guys , your library helped me alot ;)
On Sat, Apr 18, 2015 at 5:08 AM ogaclejapan [email protected]
wrote:
Hi, @saeedsh92 https://github.com/saeedsh92
The default tab attribute does not support the typeface.
Try try using the layout of the custom tab.e.g.
custom_tab_with_typeface.xm:
tab_layout.xml:
<com.ogaclejapan.smarttablayout.SmartTabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@id/viewpagertab"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_height"
...
app:stl_customTabTextLayoutId="@layout/custom_tab_with_type_face"
app:stl_customTabTextViewId="@id/custom_text"
/>—
Reply to this email directly or view it on GitHub
#5 (comment)
.
from smarttablayout.
Why you don't use some concepts of this library on this?
https://github.com/leonardoxh/CustomFont
from smarttablayout.
@ogaclejapan This don't work with me.
Return: Error:(38, 50) No resource found that matches the given name (at 'stl_customTabTextViewId' with value '@id/custom_font').
from smarttablayout.
Hi, @ppamorim
Hmm,
In the same way in 'CustomTabText' of demo application makes use of the 'stl_customTabTextViewId', but the demo application running in your environment?
Or, Does this problem has occurred when using the CustomFont?
https://github.com/leonardoxh/CustomFont
from smarttablayout.
@ogaclejapan
I've use the same way of the demo application.
I tried to use customFont and the simple TextView, no one works.
from smarttablayout.
why you don't use anything more expressive? Look like "app:font"?
from smarttablayout.
Hi, @ppamorim
I tried, there is no problem in my environment.
https://github.com/ogaclejapan/SmartTabLayout/tree/issue-5
from smarttablayout.
I am also using other custom font library within the my app.
https://github.com/ogaclejapan/Qiitanium/blob/master/qiitanium/src/main/java/com/ogaclejapan/qiitanium/presentation/activity/TopActivity.java#L107
from smarttablayout.
I do not know why you can not use in your environment.
from smarttablayout.
I try to use the base TextView but still not working.
from smarttablayout.
Only attribute "stl_customTabTextViewId" don't work. if I remove from xml, it works.
from smarttablayout.
Thank you for testing.
Could you show your defined custom layout file?
I want to see the code for this point in your defined layout.
https://github.com/ogaclejapan/SmartTabLayout/blob/master/library/src/main/java/com/ogaclejapan/smarttablayout/SmartTabLayout.java#L438-452
from smarttablayout.
@ppamorim
I think you are placing the SmartTabLayout inside another layout, right? (i.e. SmartTabLayout is not the root layout of the XML)
stl_customTabTextViewId only works when SmartTabLayout is a root layout so try to create a layout xml with SmartTabLayout as root layout and include the xml back to your original layout, then it works.
from smarttablayout.
@kaiyan910 I could use! Relax...
from smarttablayout.
@kaiyan910 thank you so much...
from smarttablayout.
thx @ashkanSp !
i create "SmartTabLayoutPro.class"
in java code replace "SmartTabLayoutPro" instead "SmartTabLayout"
and in layout replace my class directory (for me is "ir.dariche.ui.SmartTabLayoutPro") instead "com.ogaclejapan.smarttablayout.SmartTabLayout"
and it works!
from smarttablayout.
Related Issues (20)
- PagerAdapter for View-based Page
- java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
- Its not working with ViewPager2? HOT 7
- Selected Text Color
- custom integration
- How to change tab text color dynamically from coding end.
- Background Color is not 100 percent white !!!
- how to set indicator's width to the textview's width
- Changing stl_defaultTabTextSize programmatically
- Nested Tabs
- Only works for 2 tabs. the 3rd tab does not render content HOT 1
- Me HOT 1
- H
- how to unselect all tab?
- Viewpager2 not supported
- How Do I disable scrolling right and left.
- 指示线跟文字根本不匹配 HOT 1
- Doesn't inherit font style from theme an style xml file
- How to get Indicator Thickness Trick 1 style for the tab buttons. HOT 1
- How do I set up icons instead of letters?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smarttablayout.