GithubHelp home page GithubHelp logo

Comments (18)

ashkanSp avatar ashkanSp commented on September 21, 2024 1

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.

ogaclejapan avatar ogaclejapan commented on September 21, 2024

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.

saeedsh92 avatar saeedsh92 commented on September 21, 2024

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.

ppamorim avatar ppamorim commented on September 21, 2024

Why you don't use some concepts of this library on this?

https://github.com/leonardoxh/CustomFont

from smarttablayout.

ppamorim avatar ppamorim commented on September 21, 2024

@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.

ogaclejapan avatar ogaclejapan commented on September 21, 2024

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?

https://github.com/ogaclejapan/SmartTabLayout/blob/master/demo/src/main/res/layout/demo_custom_tab_text.xml

Or, Does this problem has occurred when using the CustomFont?
https://github.com/leonardoxh/CustomFont

from smarttablayout.

ppamorim avatar ppamorim commented on September 21, 2024

@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.

ppamorim avatar ppamorim commented on September 21, 2024

why you don't use anything more expressive? Look like "app:font"?

from smarttablayout.

ogaclejapan avatar ogaclejapan commented on September 21, 2024

Hi, @ppamorim

I tried, there is no problem in my environment.
https://github.com/ogaclejapan/SmartTabLayout/tree/issue-5

from smarttablayout.

ogaclejapan avatar ogaclejapan commented on September 21, 2024

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.

ogaclejapan avatar ogaclejapan commented on September 21, 2024

I do not know why you can not use in your environment.

from smarttablayout.

ppamorim avatar ppamorim commented on September 21, 2024

I try to use the base TextView but still not working.

from smarttablayout.

ppamorim avatar ppamorim commented on September 21, 2024

Only attribute "stl_customTabTextViewId" don't work. if I remove from xml, it works.

from smarttablayout.

ogaclejapan avatar ogaclejapan commented on September 21, 2024

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.

kaiyan910 avatar kaiyan910 commented on September 21, 2024

@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.

ppamorim avatar ppamorim commented on September 21, 2024

@kaiyan910 I could use! Relax...

from smarttablayout.

Leeeyou avatar Leeeyou commented on September 21, 2024

@kaiyan910 thank you so much...

from smarttablayout.

Dot01110011 avatar Dot01110011 commented on September 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.