how to show text in lower case in android? -
i try implement tabs in android .i able implement tab in android android text display in capital .i don’t want show tab text in capital letter . can show text in same format given in code
here manifest file
<resources> <!-- base application theme. --> <style name="apptheme" parent="android:theme.holo"> <!-- customize theme here. --> <item name="android:textappearance">?android:attr/textappearancesmall</item> <item name="android:textallcaps">false</item> </style> </resources>
manifest file
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.naveen.tabsfavourite" > <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
java code
import android.app.actionbar; import android.os.bundle; import android.support.v4.app.fragmentactivity; import android.support.v4.view.viewpager; public class mainactivity extends fragmentactivity implements actionbar.tablistener { viewpager viewpager; fragmentpageradapter fragmentpageradapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final actionbar actionbar =getactionbar(); viewpager = (viewpager) findviewbyid(r.id.pager); fragmentpageradapter =new fragmentpageradapter(getsupportfragmentmanager()); viewpager.setadapter(fragmentpageradapter); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); actionbar.addtab(actionbar.newtab().settext("stations").settablistener(this)); actionbar.addtab(actionbar.newtab().settext("fav station").settablistener(this)); viewpager.setonpagechangelistener(new viewpager.onpagechangelistener() { @override public void onpagescrolled(int i, float v, int i1) { } @override public void onpageselected(int i) { actionbar.setselectednavigationitem(i); } @override public void onpagescrollstatechanged(int i) { } }); } @override public void ontabselected(actionbar.tab tab, android.app.fragmenttransaction ft) { viewpager.setcurrentitem(tab.getposition()); } @override public void ontabunselected(actionbar.tab tab, android.app.fragmenttransaction ft) { } @override public void ontabreselected(actionbar.tab tab, android.app.fragmenttransaction ft) { } }
use design support library > tabs
add styles tablayout in styles.xml
<style name="tabtextappearance" parent="textappearance.design.tab"> <item name="textallcaps">false</item> </style>
then add attribute as:
<android.support.design.widget.tablayout android:id="@+id/tabs" app:tabtextappearance="@style/tabtextappearance" android:layout_width="match_parent" android:layout_height="wrap_content" />
i tested it. it'll work.
thanks
Comments
Post a Comment