Android Question use custom font in xml

Discussion in 'Android Questions' started by ArminKH, Jul 20, 2015.

  1. ArminKH

    ArminKH Well-Known Member

    hi i'm using MSMaterialDrawer Lib which is created by @thedesolatesoul
    as you can see on this thread http://www.b4x.com/android/forum/threads/msmaterialdrawer.53883/

    we have a drawer which is not customizable and as you can see on this thread http://www.b4x.com/android/forum/threads/change-msmaterialdrawers-items-gravity.56318/#post-354775
    i'm looking for a way to edit xml files to adjusting drawer for write to left language like PERSIAN
    after some tests on xml file i'm succed to change the gravity for each item of drawer and now thats okay for persian language
    but i'm sure you know the roboto font or sans serif which is default font for item's title is not suitable for all non-english languages,so i want to use my custom font for best results
    here is my attrs.xml codes
    Code:
    <?xml version="1.0" encoding="utf-8"?><resources>[/SIZE][/SIZE]
    [SIZE=
    4][SIZE=3]
        <declare-styleable name=
    "MaterialDrawer">
            <attr name=
    "material_drawer_window_background" format="color|reference"/>
            <attr name=
    "material_drawer_background" format="color|reference"/>

            <attr name=
    "material_drawer_icons" format="color|reference"/>
            <attr name=
    "material_drawer_primary_text" format="color|reference"/>
            <attr name=
    "material_drawer_primary_icon" format="color|reference"/>
            <attr name=
    "material_drawer_secondary_text" format="color|reference"/>
            <attr name=
    "material_drawer_hint_text" format="color|reference"/>
            <attr name=
    "material_drawer_divider" format="color|reference"/>

            <attr name=
    "material_drawer_selected" format="color|reference"/>
            <attr name=
    "material_drawer_selected_text" format="color|reference"/>
            <!-- material drawer header attrs-->
            <attr name=
    "material_drawer_header_selection_text" format="color|reference"/>
        </declare-styleable>

        <declare-styleable name=
    "ScrimInsetsView">
            <attr name=
    "siv_insetForeground" format="reference|color"/>
        </declare-styleable>

        <declare-styleable name=
    "BezelImageView">
            <attr name=
    "biv_maskDrawable" format="reference"/>
            <attr name=
    "biv_selectorOnPress" format="color|reference"/>
        </declare-styleable>

    </resources>


    and this is my xml code in material_drawer_item_primary.xml file which is a file of drawer in Layout folder in Res
    Code:
    <?xml version="1.0" encoding="utf-8"?>[/SIZE][/SIZE]
    [SIZE=
    4][SIZE=3]
    <RelativeLayout xmlns:android=
    "http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

            android:layout_width=
    "match_parent"
            android:layout_height=
    "@dimen/material_drawer_item_primary"
            android:paddingLeft=
    "@dimen/material_drawer_vertical_padding"
            android:paddingStart=
    "@dimen/material_drawer_vertical_padding"
            android:paddingRight=
    "@dimen/material_drawer_vertical_padding"
            android:paddingEnd=
    "@dimen/material_drawer_vertical_padding">

        <
    ImageView
            android:
    id="@+id/icon"
            android:layout_width=
    "@dimen/material_drawer_item_primary"
            android:layout_height=
    "@dimen/material_drawer_item_primary"
            android:paddingTop=
    "@dimen/material_drawer_item_primary_icon_padding"
            android:paddingBottom=
    "@dimen/material_drawer_item_primary_icon_padding"
            android:paddingLeft=
    "@dimen/material_drawer_item_primary_icon_padding_right"
            android:paddingStart=
    "@dimen/material_drawer_item_primary_icon_padding_right"
            android:layout_marginLeft=
    "@dimen/material_drawer_item_padding"
            android:layout_marginStart=
    "@dimen/material_drawer_item_padding"
            android:layout_alignParentEnd=
    "true"
            android:layout_alignParentRight=
    "true"
            android:layout_gravity=
    "center_vertical"/>


        <LinearLayout
            android:layout_toLeftOf=
    "@id/icon"
            android:layout_toStartOf=
    "@id/icon"
            android:layout_toRightOf=
    "@+id/badge"
            android:layout_toEndOf=
    "@+id/badge"
            android:layout_width=
    "match_parent"
            android:layout_height=
    "match_parent"
            android:layout_centerInParent=
    "true"
            android:
    gravity="center_vertical|end"
            android:orientation=
    "vertical">
          
            <
    TextView
                android:
    id="@+id/name"
                android:fontFamily=
    "sans-serif"
                android:layout_width=
    "match_parent"
                android:layout_height=
    "wrap_content"
                android:textSize=
    "@dimen/material_drawer_item_primary_text"
                android:
    gravity="center_vertical|right"
                android:lines=
    "1"
                android:singleLine=
    "true"
                tools:text=
    "Some drawer text"/>
            <
    TextView
                android:
    id="@+id/description"
                android:fontFamily=
    "sans-serif"
                android:layout_width=
    "match_parent"
                android:layout_height=
    "wrap_content"
                android:textSize=
    "@dimen/material_drawer_item_primary_description"
                android:
    gravity="center_vertical|right"
                android:lines=
    "1"
                android:singleLine=
    "true"
                tools:text=
    "Some drawer text"/>
        </LinearLayout>

        <
    TextView
            android:
    id="@+id/badge"
            android:fontFamily=
    "sans-serif"
            android:layout_width=
    "wrap_content"
            android:layout_height=
    "match_parent"
            android:textSize=
    "@dimen/material_drawer_item_primary_text"
            android:
    gravity="center_vertical|start"
            android:layout_alignParentStart=
    "true"
            android:layout_alignParentLeft=
    "true"
            android:lines=
    "1"
            android:singleLine=
    "true"
            tools:text=
    "99"/>
    </RelativeLayout>


    so every body are familar with xml please help me
    how is possible to set my custom font to each item of my drawer
    thanx all
     
    Last edited: Jul 20, 2015
  2. DonManfred

    DonManfred Expert Licensed User

    This kind of questions needs someone with better knowledge of xml-design (android design knowledge).
    Most of the people here does not have this knowledge (me included)
     
    lemonisdead, RandomCoder and ArminKH like this.
  3. ArminKH

    ArminKH Well-Known Member

    thank u @DonManfred but then erel say dont limit your question to one member :D
     
    Last edited: Jul 21, 2015
    RandomCoder likes this.
  4. ArminKH

    ArminKH Well-Known Member

  5. mshafiee110

    mshafiee110 Member Licensed User

    Hi @ArminKH
    how are you?Is there something you found in this case؟
    I am giiiiring it.
     
Loading...